Tip 1 : Practise more and more questions over Leetcode or hackerrank or codechef etc platform
Tip 2 : Practise LLD questions as well if you are experienced.
Tip 1 : Quantify the work you did so far (ex. impact of your work on customer or by what percent productivity increased.)
Tip 2 : Have a one pager eye-catching resume.
Questions were medium to hard level



N = 3
A = [ 3, 4, 5 ]
Explanation :
One of the optimal ways to play the game is :
Ninja removes 3 stones from the first pile : [ 0, 4, 5 ].
Friend removes 3 stones from the second pile : [ 0, 1, 5 ].
Ninja removes 3 stones from the third pile : [ 0, 1, 1 ].
Friend removes 1 stone from the second pile : [ 0, 0, 1 ].
Ninja removes 1 stones from the third pile : [ 0, 0, 0 ].
Thus Ninja wins the game here.



Let the price of Ninja Coin for 5 consecutive days is [4, 2, 3, 3, 7].
Then the span of Ninja Coin on the 0th day is 1 because we cannot move backward from day 0.
The span of Ninja Coin on the 1st day is 1 because the price on day 0 is 4 which is greater than 2, so the only day 1 is counted.
The span of Ninja Coin on the 2nd day is 2 because the price on day 2 and day 1 is less than or equal to 3 and then on day 0 price is 4 which is greater than 3, so we count day 2 and day 1.
The span of Ninja Coin on the 3rd day is 3 because the price on day 3, day 2, and day 1 is less than or equal to 3, and on day 0 price is 4 which is greater than 3, so we count day 3, day 2, and day 1.
The span of Ninja Coin on the 4th day is 5 because its value is higher than all previous days values.
Thus you should return an array/list [1, 1, 2, 3, 5].
Coding round



• The left subtree of a node contains only nodes with data less than the node’s data.
• The right subtree of a node contains only nodes with data greater than the node’s data.
• Both the left and right subtrees must also be binary search trees.
'P' = 1, 'Q' = 3
tree = 2 1 4 -1 -1 3 -1 -1 -1,
The BST corresponding will be-

Here, we can clearly see that LCA of node 1 and node 3 is 2.
The idea is to traverse the tree starting from the root. If any of the given keys (n1 and n2) matches with the root, then the root is LCA (assuming that both keys are present). If the root doesn’t match with any of the keys, we recur for the left and right subtree. The node which has one key present in its left subtree and the other key present in the right subtree is the LCA. If both keys lie in the left subtree, then the left subtree has LCA also, otherwise, LCA lies in the right subtree



1. You can not slant the container i.e. the height of the water is equal to the minimum height of the two lines which define the container.
2. Do not print anything, you just need to return the area of the container with maximum water.

For the above Diagram, the first red marked line is formed between coordinates (2,0) and (2,10), and the second red-marked line is formed between coordinates (5,0) and (5,9). The area of water contained between these two lines is (height* width) = (5-2)* 9 = 27, which is the maximum area contained between any two lines present on the plane. So in this case, we will return 3* 9=27.
The idea is : to compute area, we need to take min(height[i],height[j]) as our height. Thus if height[i]height[j] then all the other i's can be ignored for that particular j.
Coding related problem



In the below histogram where array/list elements are {2, 1, 5, 6, 2, 3}.
The area of largest rectangle possible in the given histogram is 10.
Step 1 : First we will take two arrays left_smaller[] and right_smaller[] and initialize it with -1 and n respectively.
Step 2 : For every element we will store the index of previous smaller and next smaller element in left_smaller[] and right_smaller[] arrays respectively.
(It will take O(n) time).
Step 3 : Now for every element we will calculate area by taking this ith element as the smallest in the range left_smaller[i] and right_smaller[i] and multiplying it with the difference of left_smaller[i] and right_smaller[i].
Step 4 : We can find the maximum of all the area calculated in step 3 to get the desired maximum area.



1. Delete a character
2. Replace a character with another one
3. Insert a character
Strings don't contain spaces in between.
The idea is to process all characters one by one starting from either from left or right sides of both strings.
Let us traverse from right corner, there are two possibilities for every pair of character being traversed.
m: Length of str1 (first string)
n: Length of str2 (second string)
If last characters of two strings are same, nothing much to do. Ignore last characters and get count for remaining strings. So we recur for lengths m-1 and n-1.
Else (If last characters are not same), we consider all operations on ‘str1’, consider all three operations on last character of first string, recursively compute minimum cost for all three operations and take minimum of three values.
Insert: Recur for m and n-1
Remove: Recur for m-1 and n
Replace: Recur for m-1 and n-1
This was focused on the work I previously have done. It was more focused on leadership principles,
He put me in different scenarios to get to know how did I reach and also know how I handled things.
Tip 1 : Be genuine to the asked things
Tip 2 : Prepare well to answer behavioural questions.
Tip 3 : Recall all the past good & bad experience before interview



1. push(data) :
This function should take one argument of type integer. It pushes the element into the stack and returns nothing.
2. pop() :
It pops the element from the top of the stack and returns nothing.
3. top() :
It returns the element being kept at the top of the stack.
4. getMin() :
It returns the smallest element present in the stack.
Query-1(Denoted by an integer 1): Pushes integer data to the stack. (push function)
Query-2(Denoted by an integer 2): Pops the data kept at the top of the stack. (pop function)
Query-3(Denoted by an integer 3): Fetches and returns the data being kept at the top of the stack. (top function)
Query-4(Denoted by an integer 4): Returns the smallest element present in the stack. (getMin() function)

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?