Tip 1 : Code More
Tip 2 : Study Data Structures
Tip 3 : Be Confident
Tip 1 : Mention only what you are confident about
Tip 2 : Mention tools & technologies used in the project as well
25 mcqs and 2 coding questions
(It was a part of Amazewow process via Amazewit https://www.amazewit.in/)
Timing- any time between 22-24 may 2020
Webcam was on.
There can be more than one subsequences with the longest length.
For the given array [5, 0, 3, 2, 9], the longest decreasing subsequence is of length 3, i.e. [5, 3, 2]
Try to solve the problem in O(N log N) time complexity.
I first thought of the brute force approach.
Then tried to solve for LIS which I had already solved once.
Then implemented the approach of DP for LDS.
If the given array is [1, 3, 2], then you need to return [3, -1, -1]. Because for 1, 3 is the next greater element, for 3 it does not have any greater number to its right, and similarly for 2.
It held at morning 10 AM.
The interviewer was very friendly.
I was asked to solve 2 coding questions and was continuously provided with hints by the interviewer.
Question was on Array and Trees.
Input: 'N' = 2, 'M' = 3, 'MAT' = [[1, 2, 3], [2, 0, 0]]
Output: 6
The weight of first row is 1 + 2 + 3 = 6
The weight of the second row is 2 + 0 + 0 = 2; hence the answer will be a maximum of 2 and 6, which is 6.
I first thought of the brute force approach using 2 for loops.
Then I thought of using a Stack.
Then by using a heap.
Finally, I was able to code it using 2 additional arrays (max and min).
it took O(n) time complexity and O(n2) space complexity.
Edge Case: For the first student, there is no lighter student in front but we only have to consider heavy students for him.
Similarly, for the last student, only the lighter student will be checked.
You need to modify the given tree only. You are not allowed to create a new tree.
For the given binary search tree
11 will be replaced by {15 + 29 + 35 + 40}, i.e. 119.
2 will be replaced by {7 + 11 + 15 + 29 + 35 + 40}, i.e. 137.
29 will be replaced by {35 + 40}, i.e. 75.
1 will be replaced by {2 + 7 + 11 + 15 + 29 + 35 + 40}, i.e. 139.
7 will be replaced by {11 + 15 + 29 + 35 + 40}, i.e. 130.
15 will be replaced by {15 + 29 + 35 + 40}, i.e. 104.
40 will be replaced by 0 {as there is no node with a value greater than 40}.
35 will be replaced by {40}, i.e. 40.
First I wrote the post order traversal of input,
Then by simply doing post-order traversal and performing swapping in between.
Morning 8 AM.
The interviewer was very friendly provided with various hints.
It was covering complex coding questions on Tree Data Structures.
For the given binary tree: [1, 2, 3, -1, -1, 4, 5, -1, -1, -1, -1]
Start Node: 3
1
/ \
2 3
/ \
4 5
Output: 2
Explanation :
In the zeroth minute, Node 3 will start to burn.
After one minute, Nodes (1, 4, 5) that are adjacent to 3 will burn completely.
After two minutes, the only remaining Node 2 will be burnt and there will be no nodes remaining in the binary tree.
So, the whole tree will burn in 2 minutes.
I first thought of DFS, and BFS approaches but then tried using heap but couldn't solve since the approach was wrong.
Since I messed up in the first question and already wasted a lot of time. I couldn't come u with any approach.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
Which operator is used for exponentiation in Python?