Tip 1 : Code daily
Tip 2 : Study Data Structures
Tip 3 : Be Confident
Tip 1 : Mention only what you are confident about
Tip 2 : Mention tools & technologies used in the project as well
Two coding questions were there and each round was qualifying round



[1, 2, 3, 4] is a strictly increasing array, while [2, 1, 4, 3] is not.
I first thought of the brute force approach.
Then tried to solve for LIS which I had already solved once.
Then implemented the approach of DP for LDS.



Input: 'a' = [7, 12, 1, 20]
Output: NGE = [12, 20, 20, -1]
Explanation: For the given array,
- The next greater element for 7 is 12.
- The next greater element for 12 is 20.
- The next greater element for 1 is 20.
- There is no greater element for 20 on the right side. So we consider NGE as -1.
I solved using Stack



Input: 'N' = 2, 'M' = 3, 'MAT' = [[1, 2, 3], [2, 0, 0]]
Output: 6
The weight of first row is 1 + 2 + 3 = 6
The weight of the second row is 2 + 0 + 0 = 2; hence the answer will be a maximum of 2 and 6, which is 6.



Cost of searching a key is its frequency multiplied by its level number in the BST.
Input keys = [ 1, 3, 5 ]
Frequency = [ 3, 10, 7 ]
All the unique BST possible from the given keys are:

Among all these possible BST, the minimum cost is obtained from the below BST:

Cost = 1 * (freq of 3) + 2 * (freq of 1) + 2 * (freq of 5) = 30
where 1 is the level of node 3, 2 is the level of the node 1 and node 5.
This round was also coding round



Choose a node of the tree, swap its left and right subtree i.e the left subtree will become the right one, and vice versa.
1. A binary tree is a tree in which each node has at most two children.
2. The left subtree of a node, is the tree in which the left child of the node is the root of that tree, and the same holds for the right subtree.
3. The given operation can be performed on any node at any level of the given trees.
4. Two empty trees are also said to be isomorphic.



Use zero-based indexing for the nodes.
The tree is always rooted at 0.
This using Recursion technique in a optimized way.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is recursion?