Tip 1 : For JTG, Binary Trees should be the primary focus while preparing DSA.
Tip 2 : Practicing 4-5 questions daily
Tip 1 : If applying for a Fresher position, do add your DSA ratings of different portals.
Tip 2 : When mentioning projects, also mention the highlights of your projects.
This round started with 2 DSA Questions where we need to first explain the most optimal approach and then were asked to write code on paper. This was a followed by a short discussion on my projects mentioned in the resume



1. The value of any node will not be equal to zero.
2. Subtree of a node X is all the nodes that are below X and X itself.
3. For example in the tree given below, nodes 1, 2 and 3 are in subtree of 1.

4. Subtree sum of X is the sum value of all the nodes in subtree of X.
5. Binary tree is a tree wherein each node has at most two children.
6. Any two nodes may have the same value associated with it.
Initialize an Ans equal to negative infinity where we will store the max subarray sum.
Traverse all the nodes of the tree using preorder traversal.


Input: Initial Linked List: 1 -> 5 -> 2
Output: Modified Linked List: 1 -> 5 -> 3
Explanation: Initially the number is 152. After incrementing it by 1, the number becomes 153.
Used recursion, and while falling back incremented the last number, if anything needed to carry forwarded, returned it from the function and then added it to previous digit.
2 DSA Questions
First we needed to tell the most optimal approach and then write the code on paper



Try to solve the problem in 'Single Scan'. ' Single Scan' refers to iterating over the array/list just once or to put it in other words, you will be visiting each element in the array/list just once.
Used 2 pointer to virtually divide array in 3 sections and used the second pointer to iterate and place each element in the correct place.



If the input string is ‘str’ = ”aazbbby”, then your output will be “azby”.
Note that we are just removing adjacent duplicates.
Used recursion to traverse and kept check if it's a duplicate and removed it while traversing back.
2 Algorithmic Questions were asked in this round



Suppose, Ninja is stuck at node 62. The possible exit points in the maze are: 40, 10, and 20. From all the possible exit points the closest ones are 10 and 20 which are at a distance of 1 unit.
Used modified LCA to solve the question



For the given binary tree:

Output: 96553210
Explanation: After concatenating all the numbers in the above binary tree this is the largest number that can be formed.
A simple solution would be to store all the node values to the list/array by traversing the whole Binary Tree and the problem now is that given a list of non-negative integers, arrange them such that they form the largest number.

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?