Tip 1: Make sure your computer science fundamentals are very clear.
Tip 2: You should know the complexity of the code you write and understand the internal implementation of the data structures you use while coding.
Tip 3: You should know everything you write in your resume.
Tip 4: Practice a lot of programming problems and participate in competitive programming contests.
Tip 1: Be honest about what you write in your resume.
Tip 2: Include at least two projects.
Tip 3: Maintain a concise and self-explanatory one-page resume.
Tip 4: Highlight only your technical achievements.
This round was to test the coding ability of the candidate. He jumped straight to the coding questions on the HackerRank platform. He was extremely helpful throughout the interview.


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.
We can find all adjacent valley/peak pairs and calculate the profits easily. Instead of accumulating all these profits like in Buy & Sell Stock II, we need the highest k profits.
The key point is when there are two v/p pairs (v1, p1) and (v2, p2), satisfying v1 <= v2 and p1 <= p2, we can either make one transaction at [v1, p2], or make two at both [v1, p1] and [v2, p2]. The trick is to treat [v1, p2] as the first transaction, and [v2, p1] as the second. Then we can guarantee the right max profits in both situations, p2 - v1 for one transaction and p1 - v1 + p2 - v2 for two.
Finding all v/p pairs and calculating the profits takes O(n) since there are up to n/2 such pairs. And extracting k maximums from the heap consumes another O(klgn).



1. put(U__ID, value): Insert the value in the cache if the key(‘U__ID’) is not already present or update the value of the given key if the key is already present. When the cache reaches its capacity, it should invalidate the least frequently used item before inserting the new item.
2. get(U__ID): Return the value of the key(‘U__ID’), present in the cache, if it’s present otherwise return -1.
1) The frequency of use of an element is calculated by a number of operations with its ‘U_ID’ performed after it is inserted in the cache.
2) If multiple elements have the least frequency then we remove the element which was least recently used.
Type 1: for put(key, value) operation.
Type 2: for get(key) operation.
We perform the following operations on an empty cache which has capacity 2:
When operation 1 2 3 is performed, the element with 'U_ID' 2 and value 3 is inserted in the cache.
When operation 1 2 1 is performed, the element with 'U_ID' 2’s value is updated to 1.
When operation 2 2 is performed then the value of 'U_ID' 2 is returned i.e. 1.
When operation 2 1 is performed then the value of 'U_ID' 1 is to be returned but it is not present in cache therefore -1 is returned.
When operation 1 1 5 is performed, the element with 'U_ID' 1 and value 5 is inserted in the cache.
When operation 1 6 4 is performed, the cache is full so we need to delete an element. First, we check the number of times each element is used. Element with 'U_ID' 2 is used 3 times (2 times operation of type 1 and 1-time operation of type 1). Element with 'U_ID' 1 is used 1 time (1-time operation of type 1). So element with 'U_ID' 1 is deleted. The element with 'U_ID' 6 and value 4 is inserted in the cache.
Each key maps to the corresponding node (self._node), allowing us to retrieve the node in O(1) time.
Each frequency, freq, is mapped to a Doubly Linked List (self._freq), where all nodes in the DLinkedList share the same frequency, freq. Moreover, each node is always inserted at the head, indicating it is the most recently used.
A minimum frequency, self.minfreq, is maintained to track the minimum frequency across all nodes in this cache, ensuring that the DLinkedList with the minimum frequency can always be retrieved in O(1) time.
This round was a mix of coding and system design. The interviewer was receptive, but I was not able to perform well in the system design question.



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.
The idea is to work backward from the last index. Keep track of the smallest index that can "jump" to the last index. Check whether the current index can jump to this smallest index.
Design a Web Crawler.
Tip 1: Read articles on architecture and design.
Tip 2: Practice system design questions.
Tip 3: Talk through your thought process.

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?