Tip 1 : Practice DSA sheets
Tip 2 : focus on core subjects
Tip 3 : don’t forget do practise LLD
Tip 1 : Have some full stack projects
Tip 2 : put some intern on resume
it was a coding round, it was in the evening, I gave the coding test in the main audi of our college , in the test there were 2 coding questions and rest were mcq on os, dbms, cn and oops



For this question, you can assume that 0 raised to the power of 0 is 1.


interview round
How google predicts word when we type something



1. A binary tree is a tree in which each node has at most two children.
2. The given tree will be non-empty.
3. The given tree can have multiple nodes with the same value.
4. If there are no nodes in the tree which are at distance = K from the given node, return an empty list.
5. You can return the list of values of valid nodes in any order. For example if the valid nodes have values 1,2,3, then you can return {1,2,3} or {3,1,2} etc.

Consider this tree above. The target node is 5 and K = 3. The nodes at distance 1 from node 5 are {2}, nodes at distance 2 from node 5 are {1, 4} and nodes at distance 3 from node 5 are {6, 3}.
Create a map to store the parent of each node in the tree, Traverse the tree recursively (via depth-first search), at each step if the current node is not NULL. Store its parent in the map, then traverse the left and right subtree.
Now assume that the given node is the root of the tree. In such a case, we can simply run a breadth-first search from the root, and track the current level of the tree. When the level = ‘K’, then the current nodes in the queue will be our answer.
But the problem is if the target node is not the root, then we can’t travel to every node with only left and right pointers. So here the stored parents will help us.
Observe that in a binary tree a node can be connected to maximum 3 other nodes ie. left child, right child, and the parent. We have left and right pointers, and we have also stored the parent node.
Now simply start BFS from the target node, and for each node which is at front of the queue, push its left child, right child and parent node(provided they are not null).
When the level of BFS reaches ‘K’, break the BFS and store all the values of nodes in the queue to an array and return it.



The width of each bar is the same and is equal to 1.
Input: ‘n’ = 6, ‘arr’ = [3, 0, 0, 2, 0, 4].
Output: 10
Explanation: Refer to the image for better comprehension:

You don't need to print anything. It has already been taken care of. Just implement the given function.
interview
What is virtual memory
What is Indexing and why is it done



1) Yuki can buy 1 more blade with cost 'A.’ He now has ‘K+1’ Ninja blades.
2) Yuki could buy a ‘K’ number of blades with cost 'B.’ He now has ‘2*K’ blades.
where 'A' and 'B' are predefined and constant.
There can be two or more ways with the exact cost. You can consider any one of them, but the overall cost to reach from 0 to 'N' must be minimized.
Consider Yuki need to buy 5 blades, the cost of adding 1 blade is 2, and the cost of doubling the blades is 1 then you have to perform the following operations:
1) Doubling 0 will result in 0 only, so add 1 blade to 0 blades with cost 2. Total cost becomes 2.
2) Next, you can either double 1 to reach 2 or add 1 blade. But since the cost of doubling is less than that of adding, so double 1 with cost 1. Total cost becomes 3.
3) Doubling 2 will result in 4 with a cost of 1. Total becomes 4.
4) Adding 1 in 4 will result in 5 (which is the desired number) with a cost of 2. The total cost to reach 5 becomes 6.

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?