Tip 1 : Kindly prepare basics of data structures properly.
Tip 2 : Always have an answer ready for some questions on your projects.
Tip 3 : Always have basic knowledge of the tech stack being used.
Tip 1 : Always have your resume well structured
Tip 2 : Use max 2 fonts for headings and details.
The round was 11 in the morning. It had 2 medium questions and some mcq related to leadership principles.



1. The grid has 0-based indexing.
2. A rotten orange can affect the adjacent oranges 4 directionally i.e. Up, Down, Left, Right.
Firstly i used naive approach ie Traverse through all oranges in multiple rounds. In every round, rot the oranges to the adjacent position of oranges which were rotten in the last round.
but its TC was O((R*C) * (R *C)).
Then I used a queue. The idea is to use Breadth First Search. The condition of oranges getting rotten is when they come in contact with other rotten oranges. This is similar to breadth-first search where the graph is divided into layers or circles and the search is done from lower or closer layers to deeper or higher layers. In the previous approach, the idea was based on BFS but the implementation was poor and inefficient. To find the elements whose values are no the whole matrix had to be traversed. So that time can be reduced by using this efficient approach of BFS.
Total TC - O( R *C)



I used serialization of a tree ie converting a tree into a string and matching that with all the serialization outputs of all the subtrees with that tree. Below is the following approach.
class Solution {
public boolean isSubtree(TreeNode root, TreeNode subRoot) {
String s1 = serialize(root);
String s2 = serialize(subRoot);
return s1.indexOf(s2)!= -1;
}
public String serialize(TreeNode root) {
if(root==null)
return "#";
return root.val+":"+serialize(root.left)+":"+serialize(root.right);
}
}
I was able to pass most of the tescase scenarios.
The round was at 12 afternoon. The interviewer was very polite . The round was based on probem solving skills. camera was on.



'S' = "{}()".
There is always an opening brace before a closing brace i.e. '{' before '}', '(' before ').
So the 'S' is Balanced.
I was given a XML file. I need to validate if it is a valid file or not. I was given three apis 1. isClosedTag() 2. isOpenTag() 2. getTagName()
I had no clue how a valid XML looks like . So I asked the interviewer to give me an example. I discussed some inputs.
I then chose STACK to solve the question. The question was similar to validate parenthesis question.
For every opening tag , I pushed the tag to stack.
For every closing tag, I performed following approach
1. check is the stack is empty -> return false
2. check the top of stack. If top of stack is identical to current tag , then pop it.
Similarly perform for each tag, And see if your stack is emoty at the end or not.
TC - O(n) --> n - number of tags
Explain Joins in a database.
Tip 1 : Always ask the kind of database SQL or NO-SQL.
Tip 2 : If NO-SQL, it has i think no joins. If SQL explain INNER JOINS,LEFT JOIN,RIGHT JOIN
Tip 3 : Always explain through small examples.
The round was BR round. The interviewer was SDM-2 at prime video org. The round was pretty difficult as I was grinded on my projects and leadership principles constantly.



You need to modify the given tree only. You are not allowed to create a new tree.
For the given binary search tree

11 will be replaced by {15 + 29 + 35 + 40}, i.e. 119.
2 will be replaced by {7 + 11 + 15 + 29 + 35 + 40}, i.e. 137.
29 will be replaced by {35 + 40}, i.e. 75.
1 will be replaced by {2 + 7 + 11 + 15 + 29 + 35 + 40}, i.e. 139.
7 will be replaced by {11 + 15 + 29 + 35 + 40}, i.e. 130.
15 will be replaced by {15 + 29 + 35 + 40}, i.e. 104.
40 will be replaced by 0 {as there is no node with a value greater than 40}.
35 will be replaced by {40}, i.e. 40.
First I used bruteforce approach .
This method doesn’t require the tree to be a BST. Following are the steps.
Traverse node by node(Inorder, preorder, etc.)
For each node find all the nodes greater than that of the current node, sum the values. Store all these sums.
Replace each node value with their corresponding sum by traversing in the same order as in Step 1.
Then I optimised by using property of BST
By leveraging the fact that the tree is a BST, we can find an O(n) solution. The idea is to traverse BST in reverse inorder. Reverse inorder traversal of a BST gives us keys in decreasing order. Before visiting a node, we visit all greater nodes of that node. While traversing we keep track of the sum of keys which is the sum of all the keys greater than the key of the current node.
I was aked questions on elastic search as I mentioned it as one of my tech stack in CV, I was asked about kafka and relations between producer and consumers. Cross questioning was there.
Tip 1 : You dont need to have answer to all scenarios the interviewer asks. Humbly say NO if havent encountered one
Tip 2 : Please dont fake any scenario. Try to list down all the questions and prepare a well structured answer to them
Tip 3 : Always have a smile on your face while interacting in the conversation. A lot depends on how you showcase yourself.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you remove whitespace from the start of a string?