Tip 1 : Take care of time complexity of Problems
Tip 2 : Solve as much DSA Problems
Tip 3 : Show some projects you worked on
Tip 1 : links to coding portfolios
Tip 2 : add projects
Started with Introduction and few situational questions around problem solving. It was a panel of 2 people, 1 was SDE II
Gave me 3 problems to work with, no coding IDE were involved, they just asked me the approach.
1. Push(num): Push the given number in the stack.
2. Pop: Remove and return the top element from the stack if present, else return -1.
3. Top: return the top element of the stack if present, else return -1.
4. getMin: Returns minimum element of the stack if present, else return -1.
For the following input:
1
5
1 1
1 2
4
2
3
For the first two operations, we will just insert 1 and then 2 into the stack which was empty earlier. So now the stack is => [2,1]
In the third operation, we need to return the minimum element of the stack, i.e., 1. So now the stack is => [2,1]
For the fourth operation, we need to pop the topmost element of the stack, i.e., 2. Now the stack is => [1]
In the fifth operation, we return the top element of the stack, i.e. 1 as it has one element. Now the stack is => [1]
So, the final output will be:
1 2 1
What if you maintained 2 queues. One which stored the actual stack of element, and the other which stored the minimum of elements.
So when pushing new element,
min = min(top of minimum stack, current value) which is pushed to minimum stack.
However, this uses 2N memory.
3 coding questions - Backtracking, Graphs, and System Design
Sharding a DB
1. Both the strings are non-empty and are of the same length.
2. You can apply the above operations any number of times on ‘S’.
3. The operations can only be applied on the string ‘S’.
4. ‘S’ and 'R' consist of lowercase letters only.
On every step, you need to figure out if there exists one of the positions at root, using which the 2 parts of strings are scrambled strings of each other.
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?