Tip 1 : Make proper notes
Tip 2 : Revise each topic regularly
Tip 3 : Practice as much questions
Tip 1 : Make a single page resume.
Tip 2 : Highlight the tech stack used.
There were 4 sections in total to be completed in 2 hours.
Aptitude: 20 questions.
Math: 25 questions.



You can’t engage in multiple transactions simultaneously, i.e. you must sell the stock before rebuying it.
Input: N = 6 , PRICES = [3, 2, 6, 5, 0, 3] and K = 2.
Output: 7
Explanation : The optimal way to get maximum profit is to buy the stock on day 2(price = 2) and sell it on day 3(price = 6) and rebuy it on day 5(price = 0) and sell it on day 6(price = 3). The maximum profit will be (6 - 2) + (3 - 0) = 7.



n = 4, roads = [ [1, 1, 1, 0],
[1, 1, 1, 0],
[1, 1, 1, 0],
[0, 0, 0, 1] ]

So, there are ‘2’ provinces.
1. A city is connected to itself. So, for every city ‘i’, ‘roads[i][i] = 1’.
The interviewer started on a friendly note by introducing herself followed by my introduction. After that, she asked me to open any IDE and share my screen. 2 DSA problems were asked in this round.



1. You can return the list of values in any order. For example, if a valid triplet is {1, 2, -3}, then {2, -3, 1}, {-3, 2, 1} etc is also valid triplet. Also, the ordering of different triplets can be random i.e if there are more than one valid triplets, you can return them in any order.
2. The elements in the array need not be distinct.
3. If no such triplet is present in the array, then return an empty list, and the output printed for such a test case will be "-1".
The idea is to sort an input array and then run through all indices of a possible first element of a triplet. For each possible first element, we make a standard bi-directional 2Sum sweep of the remaining part of the array. Also, we want to skip equal elements to avoid duplicates in the answer without making a set or smth like that.



[2,3,4] - median is 3.
[2,3] - median is floor((2+3)/2) = 2.
The invariant of the algorithm is two heaps, small and large, each represent half of the current list. The length of smaller half is kept to be n / 2 at all time and the length of the larger half is either n / 2 or n / 2 + 1 depend on n's parity.
This way we only need to peek the two heaps' top number to calculate median.
Any time before we add a new number, there are two scenarios, (total n numbers, k = n / 2):
(1) length of (small, large) == (k, k)
(2) length of (small, large) == (k, k + 1)
After adding the number, total (n + 1) numbers, they will become:
(1) length of (small, large) == (k, k + 1)
(2) length of (small, large) == (k + 1, k + 1)
Here we take the first scenario for example, we know the large will gain one more item and small will remain the same size, but we cannot just push the item into large. What we should do is we push the new number into small and pop the maximum item from small then push it into large (all the pop and push here are heappop and heappush). By doing this kind of operations for the two scenarios we can keep our invariant.
Therefore to add a number, we have 3 O(log n) heap operations. Luckily the heapq provided us a function "heappushpop" which saves some time by combine two into one. The document says:
Push item on the heap, then pop and return the smallest item from the heap. The combined action runs more efficiently than heappush() followed by a separate call to heappop().
Alltogether, the add operation is O(logn), The findMedian operation is O(1).
There were 2 interviewers for this round. Both of them introduced themselves after which I gave my introduction. It was supposed to be more like a discussion session than an interview.
- I had mentioned my internship experience and one of them was interested to know more about it. This began a long discussion about the problem statement, the tech stack that I worked on, factors that were considered while choosing the tech stack, what was the outcome, and the overall impact of the project.
- Then he shared a google doc link and wrote a problem on it and asked me to write a function to solve it.



1. The left subtree of a node contains only nodes with data less than the node’s data.
2. The right subtree of a node contains only nodes with data greater than the node’s data.
3. The left and right subtrees must also be binary search trees.
It is guaranteed that all nodes have distinct data.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is recursion?