Tip 1 : Practice DSA questions daily (atleast 1), Be consistent.
Tip 2 : Make proper notes for last time revision of various algorithms and techniques.
Tip 3 : Do not copy projects for resume.
Tip 1 : Make a single page resume, recruiters don't have enough time to go through multi-page resume.
Tip 2 : Do not put false things on resume, be yourself as much as you can.
This round was held on Google Meet Video Call at 10:30 A.M. There was a single Interviewer and he was very helpful.
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.
After thinking for some time I got that he wants me to find the diameter of BST because diameter will be the longest path for fire to travel.
I already solved the diameter problem earlier so it doesn't took me me much time to solve it.
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.
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.
1. Buying a stock and then selling it is called one transaction.
2. You are not allowed to do multiple transactions at the same time. This means you have to sell the stock before buying it again.
Input: ‘n’ = 7, ‘prices’ = [3, 3, 5, 0, 3, 1, 4].
Output: 6
Explanation:
The maximum profit can be earned by:
Transaction 1: Buying the stock on day 4 (price 0) and then selling it on day 5 (price 3).
Transaction 2: Buying the stock on day 6 (price 1) and then selling it on day 6 (price 4).
Total profit earned will be (3 - 0) + ( 4 - 1) = 6.
First I found that this can easily be done using the brute force approach of taking a hashmap for storing all the numbers (from min value in the input range to the maximum value in the input range )with their frequency of appearance. then I will again run a loop for each query range and output the values which will be greater than k.
in this solution 50% of the test cases gives TLE.
Then I realized that I need not to run the loop for each and every range rather I should take a array of 100000 size and :
first mark the start and end of each range in one loop
then fill the frequencies for the between elements by just looping from min to max value in my range
then for each query I got my answer in constant time by subtracting the frequency of the range elements from frequency array.
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.
This was a Technical + HR interview. It was in the afternoon around 12 pm. The interviewer wanted to know whether or not I had built some projects related to this field. Most of the interview went by him asking questions based on my projects. First I was asked to explain about a project then a lot of follow-up questions were asked.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you write a single-line comment in C++?