Blog # 90 : Flipkart Interview Questions 2013 Batch
Round 1
Write a code to check if a tree is BST or not.
Modify this code to find the maximum subtree in tree which is a BST. Maximum subtree means subtree goes upto its leaves from any node.
Modify the code again to find the maximum tree which is a BST. BST can lie anywhere and it may or may not go upto its leaves.
Round 2
1. There is code like
var i;
{
..
var j;
..
}
var k;
..
var a;
{
..
var c;
{
var i;
}
..
var d;
..
}
For simplicity you may assume that there is only one variable declaration on 1 line. Now given a line number, you have to tell what all variables are valid on that line. Propose an algorithm for this.
2. Implement LRU cache. Write a code for this. LRU cache supports 3 operations,
put(key, value)
get(key)
remove(key)
P.S. This is very important and actually good question. Even if you know the answer, dont rush with it. Take your time to frame the algorithm. Always speak your thoughts. Interviewers like to know the way you are thinking in.
Round 3
1. Implement next_permutation function (similar to what is in algorithm.h).
2. Given n sequences, and starting and stopping point of every sequence with its score. For eg.
no of sequences = 5
start stop score
0 4 4
3 10 11
6 8 8
7 15 10
11 15 4
All scores are positive. You have to find the maximum subset of non overlapping sequences having maximum total sum of scores. I proposed a n^2 approach first and then modified it to nlgn.
3. Normal discussion on work culture, teams etc.