Interview Question


Country: India
Interview Type: Written Test




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

search for the mid from where the array is on the left of it decreasing and on right increasing
Can be done in O(n) time
Now take 3 pointers, low mid high and we can easily find the number using binary search

- DashDash May 15, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Search for the reset point [i.e., where the transition from high to low occurs ]. This can be done in O(log n);
Now, if the element that you need to search is
a.Greater than the value present at this location=>Doesnt exist;
b. Else, search a[o..this_index]..and a[ this_index+1...n-1];

O( log n ) on the whole for time complexity and O( 1 ) for space complexity.

*Any comments on this are most welcomed.

- Pavan Dittakavi May 22, 2012 | Flag


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