Tip 1 : Practice DP, Trees, and Graph
Tip 2 : Try to make only 1-page resume
Tip 3 : Make sure you have clarity over your projects.
Tip 1 : Make sure you have 2 good projects on your resume
Tip 2 : The resume should not be more than 1 page
This was an Online coding round with two coding questions and the time given was 90 minutes.



The distance is calculated as |i1 – i2| + |j1 – j2|, where i1, j1 are the coordinates of the current cell and i2, j2 are the coordinates of the nearest cell having value 1.
You can only move in four directions which are : Up, Down, Left and Right.
If N = 3, M = 4
and mat[ ][ ] = { 0, 0, 0, 1,
0, 0, 1, 1,
0, 1, 1, 0 }
then the output matrix will be
3 2 1 0
2 1 0 0
1 0 0 1
I solved this question in an online round using DP
1. Iterate over the matrix from top to bottom-left to right:
Update \text{dist}[i][j]=\min(\text{dist}[i][j],\min(\text{dist}[i][j-1],\text{dist}[i-1][j])+1)dist[i][j]=min(dist[i][j],min(dist[i][j−1],dist[i−1][j])+1) i.e., minimum of the current dist and distance from top or left neighbor +1, that would have been already calculated previously in the current iteration.
2. Now, we need to do the back iteration in the similar manner: from bottom to top-right to left:
Update \text{dist}[i][j]=\min(\text{dist}[i][j],\min(\text{dist}[i][j+1],\text{dist}[i+1][j])+1)dist[i][j]=min(dist[i][j],min(dist[i][j+1],dist[i+1][j])+1) i.e. minimum of current dist and distances calculated from bottom and right neighbors, that would be already available in current iteration.



A subtree of a node X is X, plus every node that is a descendant of X.
Look at the below example to see a Binary Tree pruning.
Input: [1, 1, 1, 0, 1, 0, 1, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
Output: [1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1]
For example, the input for the tree depicted in the below image would be :

1
2 3
4 -1 5 6
-1 7 -1 -1 -1 -1
-1 -1
Level 1 :
The root node of the tree is 1
Level 2 :
Left child of 1 = 2
Right child of 1 = 3
Level 3 :
Left child of 2 = 4
Right child of 2 = null (-1)
Left child of 3 = 5
Right child of 3 = 6
Level 4 :
Left child of 4 = null (-1)
Right child of 4 = 7
Left child of 5 = null (-1)
Right child of 5 = null (-1)
Left child of 6 = null (-1)
Right child of 6 = null (-1)
Level 5 :
Left child of 7 = null (-1)
Right child of 7 = null (-1)
The first not-null node (of the previous level) is treated as the parent of the first two nodes of the current level. The second not-null node (of the previous level) is treated as the parent node for the next two nodes of the current level and so on.
The input ends when all nodes at the last level are null (-1).
The above format was just to provide clarity on how the input is formed for a given tree.
The sequence will be put together in a single line separated by a single space. Hence, for the above-depicted tree, the input will be given as:
1 2 3 4 -1 5 6 -1 7 -1 -1 -1 -1 -1 -1
I solved this question in an online round using Recursion and the approach I used is
We'll use a function containsOne(node) that tells us whether the subtree at this node contains a 1, and prunes all subtrees that do not contain 1.
If for example, node.left subtree does not contain a one, then we should prune it via node.left = null.
Also, the parent needs to be checked. If for example the tree is a single node 0, the answer is an empty tree.
The round started with some Core subject questions and then an easy coding question. It went for around 60 minutes.
Tip 1 : You must have your fundamentals clear and try to be on point.
Tip 2 : Be confident while answering any question.



The given linked list is 1 -> 2 -> 3 -> 4-> NULL. Then the reverse linked list is 4 -> 3 -> 2 -> 1 -> NULL and the head of the reversed linked list will be 4.
Can you solve this problem in O(N) time and O(1) space complexity?
So this is what I explained to my interviewer
we are going to use 3 variables: prevNode, head and nextNode, that you can easily guess what are meant to represent as we go;
we will initialise prevNode to NULL, while nextNode can stay empty;
we are then going to loop until our current main iterator (head) is truthy (ie: not NULL), which would imply we reached the end of the list;
during the iteration, we first of all update nextNode so that it acquires its namesake value, the one of the next node indeed: head->next;
we then proceeding "reversing" head->next and assigning it the value of prevNode, while prevNode will become take the current value of head;
finally, we update head with the value we stored in nextNode and go on with the loop until we can. After the loop, we return prevNode.
and he was good with my answer.
This was my final round i.e HR round and it was of 30 minutes. The interviewer asked me some standard HR questions which I prepared earlier so the interview went well.
Tip 1 : Have a crisp solid intro about yourself including your skills, projects, and hobbies.
Tip 2 : I would ask you to go through all the standard questions and have your weakness and strength in mind.
Tip 3 : Try to give an answer in the domain you are applying and in the same organization.

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?