Given a binary tree, find the maximum element in it. In this tutorial, we are going to write a code to find the maximum element in a binary tree without using recursion.
For example:
In this binary tree, the maximum element is 9.
Given a binary tree, find the maximum element in it. In this tutorial, we are going to write a code to find the maximum element in a binary tree without using recursion.
For example:
In this binary tree, the maximum element is 9.
Given a binary tree, we have to write a code to print the right view of a binary tree.
The right view of a binary tree is the set of visible nodes when it is visited or seen from the right side.
For example:
Example 1:
Let’s take an example. In this binary tree, the node which is visible from the right side is 1, 3, 4, and 8.
In this tutorial, I am going to discuss a very interesting problem sort characters by frequency.
Given a string, write a method to sort it in decreasing order based on the frequency of characters.
For example:
Example 1
Input : “teee”
Output: “eeet”
Example 2:
Input: “dddbbb”
Output: “dddbbb” or “bbbddd” (Both d and b appear 3 times so any of the above output are valid)
Example 3:
Input: “Eett”
Output: “ttEe” or “tteE” (Both e and E are two different characters so the output should not be “Eett”)