Flipkart Interview Questions
- 0of 0 votes
AnswersLet's say a website attracts a lot of traffic . How would you find at what instant of time (milliseconds or seconds , assume as you want) the traffic was super high ? What data structure would you go for and why ?
- AlgoBaba May 20, 2014 in India| Report Duplicate | Flag | PURGE
Flipkart SDE1 Algorithm - 1of 1 vote
AnswersA 2D matrix with +/- numbers , write a program to return Max sum of submatrix.
- mvk May 19, 2014 in India| Report Duplicate | Flag | PURGE
Flipkart Software Engineer / Developer - 1of 1 vote
AnswersWrite a program to return minimum number of swaps required to convert this binary tree into a BST.
- mvk May 19, 2014 in India| Report Duplicate | Flag | PURGE
Flipkart Software Engineer / Developer Data Structures - 1of 1 vote
AnswersAn extension of Dijkstra's algorithm:
- poorna.chandra.akp April 28, 2014 in United States
In a graph each vertex represents a city.
And each edge defines the connectivity between two vertices.
Each edge has two more information
1) the distance between the two vertices
2) A Boolean flag indicating if the destination is uphill or downhill to the source.
One constraint: you can change the path from uphill to downhill or downhill to uphill only once.
E.g: initially if you are going up the hill and at some point choosed to go down the hill, you can not change to take a path which is uphill again..
Similarly you are going down the hill and at some point choosed to go up the hill, you can not change to take a path which is down hill again..
O/P: find the shortest path between source to destination.| Report Duplicate | Flag | PURGE
Flipkart SDE-2 - 2of 2 votes
AnswersInterview gave towers of Honai with 4 pegs namely: source, helper1, helper2, destination.
- poorna.chandra.akp April 28, 2014 in India
What are the minimum number of steps to move N number of discs from source to destination.
he was looking for a recursive function which defines the number of moves required for N and the minimum value for that function.| Report Duplicate | Flag | PURGE
Flipkart SDE-2 Algorithm - 0of 0 votes
AnswersMachine Coding 1 hour
- hulk April 26, 2014 in India
------------------------------
U have an organizational structure, which shows hierarchy of the organization. This hierarchy contains employees E or managers M who has some Employees or Managers reporting to M.
Employee has ( id, name, JobDesc, salary etc).
Design the data structure you would be using to store this hierarchy
problem 1: Given an ID of an employee , print all the employee ID's who are directly reporting or indirectly reporting to the manager.
problem 2: prefix search of employees by String. If employees have nishant and nikhil. If searched by "ni" we need to print all details of both nishant and nikhil.
problem 3(bonus): search should print all emloyee's and their details if a given string is subString of the name of an employee.(Like a phonebook contacts search)
P.S- This was asked to one of my friend in Flipkart.| Report Duplicate | Flag | PURGE
Flipkart SDE1 Data Structures - 0of 0 votes
AnswersGiven an array of positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be adjacent in the array.
- hulk April 26, 2014 in India
You have to print the sub-sequence also.| Report Duplicate | Flag | PURGE
Flipkart SDE-2 Algorithm - 1of 1 vote
AnswersGenerate all Kaprekar Number (refer Wiki for Kaprekar number's definition) from 1 to 999999.
- hulk April 26, 2014 in India
I gave a brute force approach of generating all number in the range and checking if it is Kaprekar or not.| Report Duplicate | Flag | PURGE
Flipkart SDE-2 Algorithm Brain Teasers - 0of 0 votes
AnswersGiven three strings a, b, c. Write a function to find the smallest subsequence in a, which contains all the characters from b but none from c.
- Green April 26, 2014 in India for Machine coding
* b and c are mutually exclusive.| Report Duplicate | Flag | PURGE
Flipkart Java Developer Coding - 0of 0 votes
AnswersCreate a Employee Database for an organization. Each employee may or may not have a manager. One employee may have many subordinates. This can grow upto any level.
- Green April 26, 2014 in India for Machine coding
* Find all the subordinates for a given employee.
* Find the manager details of an employee.
Assumptions:
* Employee contains
ID: int (Unique)
Name: string
Designation: string
Email: string
* One employee can have only one manager.
* All the information is in-memory. No database needed.| Report Duplicate | Flag | PURGE
Flipkart Java Developer Coding - 0of 0 votes
AnswersGiven a list of interval , find the maximum overlapping interval. For ex if input is (0,5) (2,9) (8,10) (6,9) then ans is 2,9 as its overlap are 3.
- Nitin April 13, 2014 in United States| Report Duplicate | Flag | PURGE
Flipkart SDE-2 Algorithm - 0of 0 votes
AnswersThere is a party going on. A favorite group has to be found out. Suppose there are five people A, B, C, D and E.
- ThanksAll April 04, 2014 in India
A, B and C knows each other. D and E knows A, B and C. So ABC is the favorite group as all of them know each othe and
evry other in the party knows them. Question was How to find this group and which datastructure/algo will be suitable?| Report Duplicate | Flag | PURGE
Flipkart Developer Program Engineer Algorithm - 0of 0 votes
AnswersA number series have numbers in the increasing order where numbers are of the form 2^m*3^n*5^p. where m,n,p are an non negative integers. The initial few number of the series are
- nikhils.codecracker March 25, 2014 in India for Retail
1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18......
Write a function to get the nth term of such a sequence.| Report Duplicate | Flag | PURGE
Flipkart SDE-2 Math & Computation - 0of 0 votes
AnswersMachine coding round : (Time 1hr)
- hulk March 19, 2014 in India
expression is given and a string testCase, need to evaluate the testCase is valid or not for Expression
Expression may contain letters [a-z]
Expression may contain "."( '.' represents any char in [a-z])
Expression may contain '*'( '*' has same property as in normal RegExp)
Expression may contain '^' ( '^' represents start of the String)
Expression may contain '$' ('$' represents end of String )
Sample cases (Exp, testCase, Result) below
1. ab, ab , true
2. a*b , aaaaaab , true
3. a*b*c*, abc , true
4. a*b*c , aaabccc, false
5. ^abc*b, abccccb , true
6 ^abc*b, abbccccb , false
7 ^abcd$, abcd , true
8 ^abc*abc$ , abcabc, true
9 ^abc.abc$, abczabc , true
9 ^ab..*abc$, abyxxxxabc, true| Report Duplicate | Flag | PURGE
Flipkart Software Engineer / Developer Algorithm - 0of 0 votes
AnswersCoding in Computer : (Time 1hr)
- hulk March 19, 2014 in India
Expression is given and a string testCase, need to evaluate the testCase is valid or not for Expression
Expression may contain letters [a-z]
Expression may contain "."( '.' represents any char in [a-z])
Expression may contain '*'( '*' has same property as in normal RegExp)
Expression may contain '^' ( '^' represents start of the String)
Expression may contain '$' ('$' represents end of String )
Sample cases (Exp, testCase, Result) below
1. ab, ab , true
2. a*b , aaaaaab , true
3. a*b*c*, abc , true
4. a*b*c , aabccc, false
5. ^abc*b, abccccb , true
6 ^abc*b, abbccccb , false
7 ^abcd$, abcd , true
8 ^abc*abc$ , abcabc, true
9 ^abc.abc$, abczabc , true
9 ^ab..*abc$, abyxxxxabc, true| Report Duplicate | Flag | PURGE
Flipkart Software Engineer / Developer Algorithm - 1of 1 vote
AnswersOne of the many ways of representing a tree is to have an array(of length same as number of nodes), where each element in the node denotes the parent of that node.
- avinash February 18, 2014 in India
Eg -
{-1, 0, 0, 1, 1} would represent a tree with -
* 0 as root
* 1 and 2 as children of 0
* 3 and 4 as children of 1
Given a similar representation, you have to print reverse level order traversal of the corresponding tree.
Level order traversal of a tree is where we traverse levels of tree one by one.
Eg -
For the above given tree, level order traversal would be -
0
1 2
3 4
And hence, the reverse level order traversal is -
3 4
1 2
0
Please note -
* An element with parent = -1 is the root element.
* An element with the least index becomes the left most child. (ie. a node with always be on left of all its siblings that have higher index than it)
* When printing a level of tree you need to maintain left to right order.
Input Format -
First line of the input contains number of nodes in the tree (N)
Next line contains N (space seperated) numbers that denote where i-th number will denote the parent node of i-th node.
Output Format -
Print reverse level order traversal of the corresponding tree, with every new level starting in a different line.
Notes/Limits -
* 1 <= N <= 50
* There will be only one root element in any given test case
* Given numbers will always form a valid undivided tree
* Output should be in the exact format as specified (including whitespaces)
Sample Test Cases -
Input -
5
-1 0 0 2 1
Output -
4 3
1 2
0
Input -
9
8 7 0 5 5 8 7 0 -1
Output -
1 6
2 7 3 4
0 5
8
Input -
45
24 42 4 30 29 43 22 15 26 36 26 16 3 22 21 41 18 16 34 41 12 29 32 30 43 15 4 38 36 -1 24 42 18 6 21 38 6 17 32 17 3
34 12 14 14
Output -
1 31
20 42 9 28
12 40 33 36
3 23 37 39 6 13 27 35
0 30 11 17 22 38 7 25
5 24 16 32 15 19
8 10 43 44 18 41
2 26 14 34
4 21
29
Input -
33
17 25 0 14 7 2 5 25 18 8 16 27 10 9 19 7 31 31 19 0 8 14 9 17 18 2 30 16 30 10 5 -1 27
Output -
13 22
26 28 4 15 9 20
6 30 1 7 3 21 8 24
5 25 14 18
12 29 11 32 2 19
10 27 0 23
16 17
31| Report Duplicate | Flag | PURGE
Flipkart Software Engineer / Developer Trees and Graphs - 2of 2 votes
AnswersThis question was a modification of question 1 in this telephonic interview
- poorna.chandra.akp February 12, 2014 in India for digital
i/p: Binary Tree
O/p: print all the pairs along a path to leaf nodes, which don't follow BST property.
Eg:-
7
2 19
8 5 12 17
13 21
46
http://pastebin.com/raw.php?i=BqrNz9pu
o/p: (8,2), (8,7)
(13, 5) ( 13, 7)
and soo on.| Report Duplicate | Flag | PURGE
Flipkart Senior Software Development Engineer - 1of 1 vote
AnswersI/P: chronological order of stock value of a particular company
- poorna.chandra.akp February 12, 2014 in India for digital
O/P: Maximum profit when you buy on a day and sell on another day.
Eg:
i/p: 79 14 3 21 104 54 12 9 94 1 96 101 5
o/p: 101| Report Duplicate | Flag | PURGE
Flipkart Senior Software Development Engineer - 0of 0 votes
AnswersI/P: Binary Tree
- poorna.chandra.akp February 12, 2014 in India for digital
O/P: Print the all pairs which do not follow BST property.
Eg:-
I/p:
7
2 19
8 5 12 17
13 21
46
Looks like formatting is screwed for the binary tree.
http://pastebin.com/raw.php?i=BqrNz9pu
o/p: (8,2) (8,5) (8,7) (13,5) (13,7) (13,12) (19,17) (21,17) (46,17) (46,21)
I told the interview that I would store the inorder traversal of the input binary tree to an array and print out the inversions.
By inversion, I mean if i<j and then if a[i] > a[j]| Report Duplicate | Flag | PURGE
Flipkart Senior Software Development Engineer - 1of 1 vote
AnswersA(1) = ()
- poorna.chandra.akp February 04, 2014 in India
A(2) = (())
A(3) = (()) ()
A(4) = (())() (())
A(5) = (())()(()) (())()
A(N) = A(N-1) + A(N-2)
I/P: N, i
O/P: A(N).charAt(i);
Interviewer was not looking at iterative or recursive solution. He was looking at a closed form solution.| Report Duplicate | Flag | PURGE
Flipkart Senior Software Development Engineer - 1of 1 vote
AnswersGiven an input string.
- poorna.chandra.akp January 30, 2014 in India for digital platform
* It has numbers from M to N in increasing order. But no prior information about the values of M and N.
* There is one missing number.
Output the missing number.
Eg.
I/p: 960961962964
O/p: 963
I/p: 12345789
o/p: 6| Report Duplicate | Flag | PURGE
Flipkart SDE-2 - 1of 1 vote
AnswersGiven an array A of n numbers we can perform 3 operations on its array elements.Their are n operations in total and ith operation is to be applied on elements from ith index to last element of the array.
- justhack4fun688 January 04, 2014 in United States
1.Reverse(R) : Reverse the elements from A[i..n]
2.Add(A) : Add X to each element from A[i..n]
3.Multiply(M) : Multiply Y to each element from A[i..n]
Note : In 2nd and 3rd operation all calculations done modulo Z.
I need to find final array after nth operation is done.
EXAMPLE : Say n=3 and array has 3 elements [1,1,1] and lets X=2 ,Y=3 , Z=1000 .If sequence of operation is ARM which means 1st operation is Add,2nd operation is Reverse and 3rd one is Multiply.Then resultant array after final operation will be [3,3,9].
I was needed to calculate this array in efficient manner in c++/java| Report Duplicate | Flag | PURGE
Flipkart Software Analyst Algorithm - 0of 0 votes
AnswersDNA sequence(a string) is given (let say strDNA) and another string to search for(let say strPat). You have to find the minimum length window in strDNA where strPat is subsequence(Write code).
- Rahul Sharma November 23, 2013 in United States| Report Duplicate | Flag | PURGE
Flipkart SDE-2 Algorithm - 6of 6 votes
AnswersYou are given two string named str1 and str2. Your task is to find the minimum window in str1 which contains all characters from string str2.
- Rahul Sharma November 09, 2013 in India| Report Duplicate | Flag | PURGE
Flipkart SDE-2 Coding - -1of 1 vote
AnswersGiven a catalog of books, with the following attributes
- it_code October 26, 2013 in India
Name
Author
Publisher
Publisher Year
Price
Inventory count
Implement functionality for
1. get / search all books (by author/by name/by publisher) Also need to support partial string search
2. Update catalog (book)
Features:
* Explain why you use a particular data structure.
* Free to choose any language, C/C++/C#/Java/Perl/Python.
* Need to design the classes appropriately, that can allow scalability, encapsulation.
* Need to allow search similar to that currently provided by Flipkart.
Code in around 1 hour.| Report Duplicate | Flag | PURGE
Flipkart Software Engineer / Developer Data Structures - 0of 0 votes
AnswersGiven an array with huge number of elements. Following two operations can be performed on the array at any time
- Anonymous September 18, 2013 in India
1. Find cumulative sum of first x numbers when x is input by user
2. Add/subtract value 't' from any index i of the array.
Find the most optimal way such that both the above requirements are optimized.| Report Duplicate | Flag | PURGE
Flipkart Arrays - 1of 1 vote
AnswersFlipkart handles millions of users looking to buy or sell products. It also provides a search bar to the user as an interface to search for items. At times when typing users may enter a query string which may be single word by mistake but the intention of the user was to type them separately. For eg.,
- nilukush August 20, 2013 in India
User may have entered flipkartmobile when in real, his / her intention was to search for flip kart mobile.
Considering above scenario, implement an algorithm to split up query string provided by user given a list of dictionary words, i.e, you will be given a list of dictionary words and the user-input query string and you have to give the split up of query string which satisfies the following requirements / properties :
1. In case of multiple split-ups, conclude on the one that is lexicographically smaller, i.e, has spaces more towards the left. For eg.,
Assume you are given the list of words : flip, kart, flipkart, mobile and user-input query string is flipkartmobile. Hence, possible split-ups are flip kart mobile and flipkart mobile. The answer / output in this case should be flip kart mobile with more spaces towards the left.
2. Number of characters in query string shall be < 500 characters. Reason being hackers may try to provide a very long input and hence, this may consume processing and result in unresponsive website ultimately.
3. Repetition of dictionary words in query string is possible. For eg.,
Assume you are given the list of words : lg, mobile and user-input query string is mobilelglg. The answer / output in this case should be mobile lg lg.
Now, format of Input and Output :
Input
4 // number of dictionary words given
flip // list of dictionary words the number equaling to input above
kart
flipkartmobile
flipkartmobile // user-input query string
Output
flip kart mobile| Report Duplicate | Flag | PURGE
Flipkart SDE-2 Algorithm - 0of 0 votes
AnswersGiven a pointer to a node in tree, you have to find the depth of that node.
- SK July 07, 2013 in India
function signature:
int depth (root, node);| Report Duplicate | Flag | PURGE
Flipkart Senior Software Development Engineer Coding - 1of 1 vote
AnswersYou given an array:
- SK July 07, 2013 in India
3, 2, 1, 6, 5, 4, 9, 8, 7
you have to find a 3 tuple which has property a < b < c, also a is before b, b is before c in array.
Answer can have multiple tuples, you have to find any one.
In this array, answer will be 3, 6, 9| Report Duplicate | Flag | PURGE
Flipkart Senior Software Development Engineer Algorithm