Need urgent help




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

We know the best case can be when elements are increasing by +1. Check the first number of an array a[0] --> 4 and number to found is 10.
diff = 10 -4 = 6.
Number​ should at most apperas at a[0+6] = a[6] --> 8 .
Repeat the process again untill you find the element. [10-8 = 2]
check for a[8] --> 10 (output the number).

- Anonymous July 30, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

How does it work for input(4,5,6,5,6,7,8,9,10,9,8,9,10,11,10,9,8,7,6,5,4,3,2,1,1,2,3,2) to find 3??

- Anonymous August 02, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

My code is
public static int FirstOccurence(int key)
{
int index=0;

while(arraySize>index)
{

if(array1[index]==key)
{
return index;
}
else
{

if(array1[index]>key)
{
index=index+array1[index]-key;

}
else
{

index=index+key-array1[index];

}
}
}
return -100;

}

- Anonymous August 11, 2014 | 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