Tip 1 : Practise problems on Leetcode and solve past year company-specific problems
Tip 2 : Be very good at OOPS concepts, study in-depth about Polymorphism, Inheritance, Friend functions, Operator Overloading
Tip 3 : Do at least one project and know every in and out about it
Tip 1 : Don't fake any project or any programming language on the resume.
Tip 2 : If you are including projects in python or experience in the python language then you must be good with OOPs concepts with implementation.
This was a programming test consisting of 3 sections with 1 question each. 25 mins for the 1st section, and 35 for the 2nd and 3rd section. Each section had its own fixed time.



I quickly implemented a brute force solution in 2-3 minutes to pass partially. Then implemented a time-efficient solution with 7^3 time complexity.



1.’Left’ and ‘Right’ both are inclusive in the range ‘Left’ to ‘Right’.
‘Left’ = ‘23’ and ‘Right’ = ‘37’

All prime numbers from ‘23’ to ‘37’ are 23, 29, 31, 37
23 is ‘megaprime’ number because ‘2’ and ‘3’ both are prime
29 is not ‘megaprime’ number because ‘9’ is not a prime
31 is not a ‘megaprime’ number because ‘1’ is not a prime number
37 is ‘megaprime’ number because ‘3’ and ‘7’ both are prime numbers
Hence there are two ‘megaprime’ numbers 23, 37 out of 23, 29, 31, 37.



Consider 0-based indexing.
Consider the array 1, 2, 3, 4, 5, 6
We can Jump from index 0 to index 1
Then we jump from index 1 to index 2
Then finally make a jump of 3 to reach index N-1
There is also another path where
We can Jump from index 0 to index 1
Then we jump from index 1 to index 3
Then finally make a jump of 2 to reach index N-1
So multiple paths may exist but we need to return the minimum number of jumps in a path to end which here is 3.
Solved in a greedy manner.
There were two interviewers on a video call. For the first 25 minutes, the first interviewer asked his questions, and later the second one. For the second 25 minutes, questions related to OOPS were discussed, and also was asked to implement few things.
1. What concepts do you know about OOPS?
2. Implement Runtime polymorphism and Compile time polymorphism.
3. What are virtual functions?
4. Write a Copy constructor for a derived class?
5. He made some changes in my base class written, he added static in front of the virtual keyboard and asked me that now tell how will it behave now?
6. Difference between endl and \n?
7. Overload the << Operator to print comma-separated members of a class?
8. Are virtual destructors possible in c++?
9. Where do we use classes and OOPS concepts in real life?
Tip 1 : Be very thorough with OOPS concepts
Tip 2 : Don't just read about OOPS do try them and write code for OOPS concepts



If the dictionary consists of the following words:-
["caa", "aaa", "aab"], and 'K' is 3.
Then, the order of the alphabet is -
['c', 'a', 'b']
If the language consists of four letters, the four letters should be the starting four letters of the English language.
However, their order might differ in the alien language.



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
I thought for a bit time then made some trees on the editor and asked him the expected output for those to get the clarity, Then I implemented the DFS were along with depth I stored the direction from parent whether reached node as Left child of a parent or right child and implement smart DFS. The interviewer was satisfied with the entire discussion.
It consisted of two coding problems which involved proper coding it and explaining each and every aspect and I have to show dry run over a few cases



A binary tree is a tree in which each parent node has at most two children.
A binary heap tree has the following properties.
1. It must be a complete binary tree. In the complete binary tree every level, except the last level, is completely filled and the last level is as far left as possible.
2. Every parent must be greater than its all children nodes.
Consider this binary tree:

Figure 1 is a complete binary tree because every level, except the last level, is completely filled and the last nodes are as far left as possible, and the level has 2 nodes both on the left side.
Figure 2 is not a complete binary tree because level 2 (level is 0 based) is not completely filled means the right child of the node (36) is missing.
There is another reason, in the last level, there can be one another node in between node (1) and node (14) to make the binary tree as far left as possible.
1. In the world of programming two types of binary heap tree possible:
a. Min-heap - if all parents nodes are lesser than its children nodes.
b. Max-heap - if all parents nodes greater than its children nodes, explained in the above figure-1.
2. In this problem binary heap tree is a binary max-heap tree.
Firstly, I solved this using DFS and BFS approach that takes O(N) time so the interviewer asked me to optimize it. Then I used this property of 2*parent,2*parent+1 to solve it in O(logN), I constructed the path from the node to root using a while loop and stored the path. Then traveled from root along that path to reach the required node or if I exceed it then return false.



Given 'N' : 5 (number of packets) and 'M' : 3 (number of students)

And chocolates in each packet is : {8, 11, 7, 15, 2}
All possible way to distribute 5 packets of chocolates among 3 students are -
( 8,15, 7 ) difference of maximum-minimum is ‘15 - 7’ = ‘8’
( 8, 15, 2 ) difference of maximum-minimum is ‘15 - 2’ = ‘13’
( 8, 15, 11 ) difference of maximum-minimum is ‘15 - 8’ = ‘7’
( 8, 7, 2 ) difference of maximum-minimum is ‘8 - 2’ = ‘6’
( 8, 7, 11 ) difference of maximum-minimum is ‘11 - 7’ = ‘4’
( 8, 2, 11 ) difference of maximum-minimum is ‘11 - 2’ = ‘9’
( 15, 7, 2 ) difference of maximum-minimum is ‘15 - 2’ = 13’
( 15, 7, 11 ) difference of maximum-minimum is ‘15 - 7’ = ‘8’
( 15, 2, 11 ) difference of maximum-minimum is ‘15 - 2’ = ‘13’
( 7, 2, 11 ) difference of maximum-minimum is ‘11 - 2’ = ‘9’
Hence there are 10 possible ways to distribute ‘5’ packets of chocolate among the ‘3’ students and difference of combination (8, 7, 11) is ‘maximum - minimum’ = ‘11 - 7’ = ‘4’ is minimum in all of the above.
I solved using recursion + dynamic programming first then I optimized it using the Binary Search approach.
It was a very friendly and chill round.
Here I was supposed to ask the questions from the hiring manager. She asked if I want to know anything about the company or any general questions. So asked him about the projects and teams at Deshaw and some other questions.
Be natural don't try to make a question out of nowhere.

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?