I recently have appeared for flipkart interview process. I would like to share it with crazyforcode and help others.
Q1. Write a code to check if a tree is BST or not.
Q2. 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.
Q1. There is code like
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.
Q2. Implement LRU cache. Write a code for this. LRU cache supports 3 operations,
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.
Q3. WAP to get the next higher palindrome of a given number.
123 -> 131 1232 -> 1331
Q1. Implement next_permutation function (similar to what is in algorithm.h).
Q2. 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.
Q3. Normal discussion on work culture, teams etc.
This is pretty much about the interview rounds. Best of luck.
Thanks Shailja Kapoor for contributing this article. If you would like to contribute, mail us your interview experience at [email protected] We will like to publish it on CrazyforCode and help other job seekers.