Tip 1 : Prepared data structure and algorithm + System Design
Tip 2 : Go through basic of CS fundamentals
Tip 1 : Mention those things only in which you are confident
Tip 2 : Try to be good in code chef
Two coding Question



In the above image, areas in green, red, and violet color are all submatrices of the original 4x4 matrix.
1. Binary valued matrix has only two values in each cell : 0 and 1.
2. A submatrix is a matrix formed by selecting certain rows and columns from a larger matrix.
3. The area of a matrix with 'h' rows and 'w' columns is equal to 'h' * 'w'.
If the height of bars of the histogram is given then the largest area of the histogram can be found. This way in each row, the largest area of bars of the histogram can be found. To get the largest rectangle full of 1’s, update the next row with the previous row and find the largest area under the histogram, i.e. consider each 1’s as filled squares and 0’s with an empty square and consider each row as the base.
Run a loop to traverse through the rows.
Now If the current row is not the first row then update the row as follows, if matrix[i][j] is not zero then matrix[i][j] = matrix[i-1][j] + matrix[i][j].
Find the maximum rectangular area under the histogram, consider the ith row as heights of bars of a histogram. This can be calculated as given in this article Largest Rectangular Area in a Histogram
Do the previous two steps for all rows and print the maximum area of all the rows.



You need to return the head to the doubly linked list.
The doubly linked list would be: 1 2 3 4 5 and can be represented as:

The problem here is simpler as we don’t need to create a circular DLL, but a simple DLL. The idea behind its solution is quite simple and straight.
If the left subtree exists, process the left subtree
Recursively convert the left subtree to DLL.
Then find the inorder predecessor of the root in the left subtree (the inorder predecessor is the rightmost node in the left subtree).
Make the inorder predecessor as the previous root and the root as the next in order predecessor.
If the right subtree exists, process the right subtree (Below 3 steps are similar to the left subtree).
Recursively convert the right subtree to DLL.
Then find the inorder successor of the root in the right subtree (in order the successor is the leftmost node in the right subtree).
Make the inorder successor as the next root and the root as the previous inorder successor.
Find the leftmost node and return it (the leftmost node is always the head of a converted DLL).
Basic introduction
Java related question(diff. b/w Hashmap and hashtable, multithreading, oops question



1. push(data) :
This function should take one argument of type integer. It pushes the element into the stack and returns nothing.
2. pop() :
It pops the element from the top of the stack and returns nothing.
3. top() :
It returns the element being kept at the top of the stack.
4. getMin() :
It returns the smallest element present in the stack.
Query-1(Denoted by an integer 1): Pushes integer data to the stack. (push function)
Query-2(Denoted by an integer 2): Pops the data kept at the top of the stack. (pop function)
Query-3(Denoted by an integer 3): Fetches and returns the data being kept at the top of the stack. (top function)
Query-4(Denoted by an integer 4): Returns the smallest element present in the stack. (getMin() function)
We define a variable minEle that stores the current minimum element in the stack. Now the interesting part is, how to handle the case when minimum element is removed. To handle this, we push “2x – minEle” into the stack instead of x so that previous minimum element can be retrieved using current minEle and its value stored in stack. Below are detailed steps and explanation of working.
Push(x) : Inserts x at the top of stack.
If stack is empty, insert x into the stack and make minEle equal to x.
If stack is not empty, compare x with minEle. Two cases arise:
If x is greater than or equal to minEle, simply insert x.
If x is less than minEle, insert (2*x – minEle) into the stack and make minEle equal to x. For example, let previous minEle was 3. Now we want to insert 2. We update minEle as 2 and insert 2*2 – 3 = 1 into the stack.
Pop() : Removes an element from top of stack.
Remove element from top. Let the removed element be y. Two cases arise:
If y is greater than or equal to minEle, the minimum element in the stack is still minEle.
If y is less than minEle, the minimum element now becomes (2*minEle – y), so update (minEle = 2*minEle – y). This is where we retrieve previous minimum from current minimum and its value in stack. For example, let the element to be removed be 1 and minEle be 2. We remove 1 and update minEle as 2*2 – 1 = 3.



Create a deque to store k elements.
Run a loop and insert first k elements in the deque. Before inserting the element, check if the element at the back of the queue is smaller than the current element, if it is so remove the element from the back of the deque, until all elements left in the deque are greater than the current element. Then insert the current element, at the back of the deque.
Now, run a loop from k to end of the array.
Print the front element of the deque.
Remove the element from the front of the queue if they are out of the current window.
Insert the next element in the deque. Before inserting the element, check if the element at the back of the queue is smaller than the current element, if it is so remove the element from the back of the deque, until all elements left in the deque are greater than the current element. Then insert the current element, at the back of the deque.
Print the maximum element of the last window.
It was Hr round, around 3pm
Asked some behavioural and conditional question.
Share a time you made a mistake at work and how you corrected it.
How you handle your stress when you have lots of work ?
Are you a multitasking person?
Tip 1 : be confident
Tip 2 : give genuine answer(put yourself in that place and than give answer) not from internet

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
Which SQL clause is used to specify the conditions in a query?