Tip 1 : Add atleast 2 good projects in your resume about which you can talk for atleast 10 minutes.
Tip 2 : Solve company tagged questions before interview
Tip 1 : Resume should be strictly 1 pager
Tip 2 : Mention all important details like your email, mobile number etc.
• The left subtree of a node contains only nodes with data less than the node’s data.
• The right subtree of a node contains only nodes with data greater than the node’s data.
• Both the left and right subtrees must also be binary search trees.
Level 1:
All the nodes in the left subtree of 4 (2, 1, 3) are smaller
than 4, all the nodes in the right subtree of the 4 (5) are
larger than 4.
Level 2 :
For node 2:
All the nodes in the left subtree of 2 (1) are smaller than
2, all the nodes in the right subtree of the 2 (3) are larger than 2.
For node 5:
The left and right subtrees for node 5 are empty.
Level 3:
For node 1:
The left and right subtrees for node 1 are empty.
For node 3:
The left and right subtrees for node 3 are empty.
Because all the nodes follow the property of a binary search tree, the above tree is a binary search tree.
I solved this question using preorder recursion in O(n) time
An integer 'a' is closer to 'X' than an integer 'b' if:
|a - X| < |b - X| or ( |a - X| == |b - X| and a < b )
if X = 4, 3 is closer to 'X' than 9, as |3-4| < |9-4| i.e., 1 < 5 and if X = 4, 2 and 6 are equally close to it, as |2-4| == |6-4| = 2, but we say 2 is closer to 4 than 6, as 2 is smaller.
I solved this question using a heap data structure in O(nlogk) time
Solved this question using Boyer Moore Voting algorithm in O(n) time
Can you try to solve this problem in O(N) time and O(1) space?
If ‘N’ = 3
Then there are 5 possible binary strings of length equal to 3 that do not contain consecutive 1’s: “000”, “001”, “010”, “100”, “101”.
what is cache?
what is round robin?
what is banker's algorithm?
what is multitasking?
preemptive vs non-preemptive.
there were 2 interviewers.
what are joins and it's different types. what is cross join?
write a query to find the nth highest salary.
what is internal fragmentation, external fragmentation, defragmentation.
cpu scheduling algorithms?
1- Visit the root node.
2- Traverse all nodes in the left subtree of the root node.
3- Traverse all the nodes in the right subtree of the root node.
For the given tree below,
Preorder traversal for the given tree will be [1, 2, 4, 5, 3]. Hence, the answer is [1, 2, 4, 5, 3].
Elements are in the level order form. The input consists of values of nodes separated by a single space in a single line. In case a node is null, we take -1 in its place.
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
Explanation :
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
Input: 'n' = 5, 'arr' = [1, 2, 3, 4, 5]
Output: 5
Explanation: From the array {1, 2, 3, 4, 5}, the largest element is 5.
It was a behavioral round.
standard behavioral questions like
why morgan stanley?
5 principles of morgan stanley?
how to resolve conflict in a team?
my internship experience?
1 low level design question to design a parking lot.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
Which SQL keyword removes duplicate records from a result set?