Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Written Test




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

calculate Sum of all page num. now subtract from n(n+1)/2... answer is missing page num

- loveCoding March 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

We still can optimize this by one operation where,
calculate the sum first and keep subtracting the page numbers and the last remaining is the page we need to find.

- anonymous March 07, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

We still can optimize this by one operation where,
calculate the sum first and keep subtracting the page numbers and the last remaining is the page we need to find.

- anonymous March 07, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I do not see the difference. Sum up and subtracted from expected sum versus expected sum subtracting all remaining page. Same~

- Anonymous March 07, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

This will work if the pages are single sided.
If the pages are double sided, then the number obtained by subtracting has to be divided by 2.

- Say March 08, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

if pages are double sided, both sides will have page numbers.. let x be the total of page numbers from 1 to n, y be the total of pages we have and z =x-y. On diving z/2 we'll get 1st number (like Say said) and on subtracting z-z/2 we'll get 2nd page number..

- Anonymous March 10, 2012 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

#define SIZE 3
int tab[SIZE];
int pages[]={1,3};

for(i=0; i<SIZE ; i++)
{
  tab[i]=0;
}

for(i=0; i<SIZE-1 ; i++)
{
  tab[pages[i]]=1;
}

for(i=0; i<SIZE ; i++)
{
  if(!tab[i]) printf("\n i: %d is missing", i);
}

- CheckThisResume.com March 07, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Similar to one missing element in the array!

- unkown March 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If you also want to rearrange the pages, better go for insertion sort :)

- Learner March 10, 2012 | 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