Tip 1 : Practice common DSA interview problems from all topics.
Tip 2 : Have at least 1 good project for discussion.
Tip 1 : Have at least one good project.
Tip 2 : Be ready to answer anything mentioned on resume.



1. Used a recursive approach first to solve the problem.
2. Optimised it using Dynamic Programming.



Can you solve each query in O(logN) ?
Used binary search to solve the problem.
DSA round - 1




For the above-linked list, if k=2, then the value at the kth i.e second node from the end is ‘12’.
1.You don’t need to take any input. It has already been taken care of. Just implement the given function and return a pointer pointing to the k-th element from the last of the linked list.
2.It is guaranteed that k<=size of the linked list.
1. Used two loops - one to find length and other to find n-k th element from first.
2. Interviewer asked me to do it in one loop; used two pointer approach to solve the problem.



1. Used a hashmap to store the sum of all the subarrays.
2. If current sum is present in the hashmap or current sum is 0, we calculate the length and store it.
3. Returned largest subarray length that we calculated.



1. A node will be in the bottom-view if it is the bottom-most node at its horizontal distance from the root.
2. The horizontal distance of the root from itself is 0. The horizontal distance of the right child of the root node is 1 and the horizontal distance of the left child of the root node is -1.
3. The horizontal distance of node 'n' from root = horizontal distance of its parent from root + 1, if node 'n' is the right child of its parent.
4. The horizontal distance of node 'n' from root = horizontal distance of its parent from the root - 1, if node 'n' is the left child of its parent.
5. If more than one node is at the same horizontal distance and is the bottom-most node for that horizontal distance, including the one which is more towards the right.
Input: Consider the given Binary Tree:

Output: 4 2 6 3 7
Explanation:
Below is the bottom view of the binary tree.

1 is the root node, so its horizontal distance = 0.
Since 2 lies to the left of 0, its horizontal distance = 0-1= -1
3 lies to the right of 0, its horizontal distance = 0+1 = 1
Similarly, horizontal distance of 4 = Horizontal distance of 2 - 1= -1-1=-2
Horizontal distance of 5 = Horizontal distance of 2 + 1= -1+1 = 0
Horizontal distance of 6 = 1-1 =0
Horizontal distance of 7 = 1+1 = 2
The bottom-most node at a horizontal distance of -2 is 4.
The bottom-most node at a horizontal distance of -1 is 2.
The bottom-most node at a horizontal distance of 0 is 5 and 6. However, 6 is more towards the right, so 6 is included.
The bottom-most node at a horizontal distance of 1 is 3.
The bottom-most node at a horizontal distance of 2 is 7.
Hence, the bottom view would be 4 2 6 3 7
1. Found the maximum width of the binary tree, then created a vector of that size and stored elements in it using bfs.
2. Used a hashmap to store elements in bfs and then passed hashmap values in an array.



Can you solve it in O(N+M) time?
If ‘N’ = 6, ‘A’ = {1, 2, 0, 3, 4, 5}, ‘M’ = 7 and ‘B’ = {3, 5, 0, 2, 1, 6, 4}.
Then, we will return {6, 6, 2, 5, -1, 6} because:
For i = 0, A[i] = 1 and the first element greater than 1 that lies to the right of it in array ‘B’ is 6.
For i = 1, A[i] = 2 and the first element greater than 2 that lies to the right of it in array ‘B’ is 6.
For i = 2, A[i] = 0 and the first element greater than 0 that lies to the right of it in array ‘B’ is 2.
For i = 3, A[i] = 3 and the first element greater than 3 that lies to the right of it in array ‘B’ is 5.
For i = 4, A[i] = 4 and there is no greater element to the right of 4 in array ‘B’.
For i = 5, A[i] = 5 and the first element greater than 5 that lies to the right of it in array ‘B’ is 6.
Used a stack and stored elements from the last which are greater and used it to calculate NGE for all elements.
Find row with second maximum cost.
Select * from table where cost in (selct max(cost) from table where cost not in select max(cost) from table);
Managerial round
Had a discussion around internship that I did. Asked me about the project that I did there. Then we moved on to personal projects followed by HR questions like What was the most challenging part, Tell me about a time when your decision had a huge negative impact; How you dealt with non-collaborative teammates.

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