Tip 1 : before interview, practice questions with company tag on websites like leetcode and see previous experiences
Tip 2 : even if you're able to solve the question, see approaches used by other people and try to solve the question in multiple ways
Tip 3 : prepare questions on leadership principles
Tip 1 : put links of your work like competitive coding profiles, hosted projects, github, etc
Tip 2 : revise everything on your resume before interview


str = "ababc"
The longest palindromic substring of "ababc" is "aba", since "aba" is a palindrome and it is the longest substring of length 3 which is a palindrome.
There is another palindromic substring of length 3 is "bab". Since starting index of "aba" is less than "bab", so "aba" is the answer.
1. Calculated LPS using DP (length1)
2. Length of shortest palindromic substring = 1 (length2)
3. Returned length1 - length2



We cannot use the element at a given index twice.
Try to do this problem in O(N) time complexity.



1) An element of the ‘COORDINATES’ array is a pair of ‘X' and ‘Y’ coordinates of a point, i.e., COORDINATES[i] = (Xi, Yi).
2) |DISTANCE| represents the absolute value of distance.
3) All points are considered to be connected if there is exactly one simple path between two points.
4) According to Wikipedia, a simple path is a path in a plane that does not have repeating points.



-The largest possible answer is N+1 (if all elements from 1-N are present), so make an array called pos, of size n+1 where n is the size of given array. Initialize it with all values = - 1
-Traverse the input array and every time you encounter a number in the range 1-n update its location in the pos array.
- now traverse the pos array and find the first position with -1 as its value. The index of that position is the first missing positive number.





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






Consider the 2 * 2 grid
Let's call the four cells in the grid as A,B,C,D. In this grid, it is allowed to move from Cell A to Cell B, Cell B to Cell D, Cell C to Cell D and Cell D to Cell C. There are two paths that start from A and ends at D:
1) A->C->D
To follow this path we need to change the value of cell A to “D” and do not need to change the value of cell C. Therefore, the total change for this path is 1.
2) A->B->D
To follow this path we need not to change any of the cell values. Therefore the total changes for this path is 0.
As we can see the minimum changes required to reach the bottom-right cell is Zero therefore the answer is 0 in this case.
Bar raiser



For the given array 'ARR' = [7, 12, 1, 20]
The next greater element for 7 is 12.
The next greater element for 12 is 20.
The next greater element for 1 is 20.
There is no greater element for 20 on the right side.
So, the output is [12, 20, 20, -1].



Let S = “abdd” and X = “bd”.
The windows in S which contain all the characters in X are: 'abdd', 'abd', 'bdd', 'bd'.
Out of these, the smallest substring in S which contains all the characters present in X is 'bd'.
All the other substring have a length larger than 'bd'.

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?