Flipkart Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
1
of 1 vote

If the sizes were not huge, we could have merged all 3 arrays into one and then done a linear scan to find numbers repeated thrice.
Here, maintain 3 pointers one for each list. If values at all 3 are same, increment commonCount. If not, increment the index of the list with the minimum value out of all 3. Keep doing this till all 3 pointers go out of range. Return commonCount

- Metta September 04, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

What if any file has duplicate order id? (A sorted list can have duplicates i believe)

- Sathish March 16, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use Map/Reduce algorythm :)

- _ManiaC_ September 06, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

well that would depend on the no. of orders :)
if you are getting only orders in order of hundreds then you dont need hadoop cluster to do the required job, a simple implementation of getting the intersection from 3 log files would do.

if log files are really big then map/reduce would help.

- bawet October 09, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Step 1: Get the files in to the arrays
Step 2: Search the First array's element in second array and third array using binary search.
If exists in second and third arrays. return the order.
Step 3: Follow this step to the entire First array.

- Karthik December 07, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

We need to take advantage of orders being sorted..

Metta's solution is best.. :)

- prit January 24, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Guys you can get a linear time algorithm by using modified merge. Using modified merge, find the common elements of first two arrays and store the result in fourth array. Again repeat the same procedure on third and fourth array. You get the answer.

By modified merge, I mean while merging select the common elements.

- neeraj.fullwithattitude September 15, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

void modifiedMerge(int A[], int B[], int size1, int size2)
{
int i = 0;
int j= 0;
while(i<size1 && j<size2)
{
if(A[i]==B[j]) printf("%d ",A[i]);//you can store it in array
else if(A[i] < B[j]) i++;
else j++;
}
}

- neeraj.fullwithattitude September 15, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

If you lyk the solution, plz. let me know :)

- neeraj.fullwithattitude September 15, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Note files are in sorted order and are huge, so in memory sort is ruled out.

Let all three files have 3 pointers if the current value of all the pointers is same, then the order is same in all files, now increment the pointers, always compare the pointer values until you reach the pointers in all three files with same value. Note increment the pointer which is lagging behind. This is a linear complexity algo.

- Amit Jain November 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This problem can be solved using Map Reduce.

Write three mapper classes which will read each file and retrieve each OrderId.
In the shuffle and Sort phase the data is segregated into block
The segregated blocks are passed to Reduce where Aggregation.

Correct me if any changes need to be done

- jkchakravarthy October 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@karthik- We should only compare the elements in array-3 which are present in array-2.

- Anonymous March 23, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

When was this interview?

- Anonymous September 05, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

doing binary search is the good solution we are actually making use of the sorted order in this solution. @karthi :)

- dhina.psg August 04, 2011 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More