Future Group, Mumbai Interview Question for Software Engineer / Developers


Country: India
Interview Type: In-Person




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

1. Use a modified version of binary search for first column (Lets name is as c1):
it return the position of the number if found
else return i such that c1[i]< searchItem < c1[i+1]
2. Now search for the searchItem if not found in the first step in ith row of the main array using binary search

- Harmit January 14, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I assume that Sorted Matrix means sorted across each row and each column, instead of sorted as per BFS.
For that case, this will not work. Try to find 4 in the following matrix:

1 2 3 4
2 5 6 7
3 6 7 8
5 7 8 9

Correct Solution:
#Start from Top-Right position.
#If it's value is greater than the search_value, move down and discard the current row.
#If it's value is lesser than search_value, move left and discard the current column.
#Else, you have found your search_value.
#Repeat until you find the search_value or reach the bottom-left.

Maximum moves: N towards left + N towards down.
So Complexity: O(N).

- -- February 09, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can you please elaborate the question more.... There is an algo which searches for a given number when rows and columns are in sorted order. Could you please clarify?

- Anonymous October 23, 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