Software Interview Questions

550,609 software interview questions shared by candidates

Given an array of length N containing numbers bounded between 1 and N with exactly one duplicate, determine what the duplicate number is in O(n) time without using more than constant memory (no making new arrays of N length).
avatar

Software Engineering Intern

Interviewed at Microsoft

4
Oct 28, 2015

Given an array of length N containing numbers bounded between 1 and N with exactly one duplicate, determine what the duplicate number is in O(n) time without using more than constant memory (no making new arrays of N length).

Here is the brain teaser question: Given integers as 1, 2, 3, 4, ..., N. Every time you remove an alternative element until only one is left. If you reach the end, just do a rounding. Return the remaining element. For example, given 1,2,3,4,5,6, you remove 1, 3, 5 and then 2, 6. So the remaining element is 4. What is the remaining element if N is 2000?
avatar

Software Engineer

Interviewed at Turn

3.7
Mar 15, 2014

Here is the brain teaser question: Given integers as 1, 2, 3, 4, ..., N. Every time you remove an alternative element until only one is left. If you reach the end, just do a rounding. Return the remaining element. For example, given 1,2,3,4,5,6, you remove 1, 3, 5 and then 2, 6. So the remaining element is 4. What is the remaining element if N is 2000?

Viewing 541 - 550 interview questions

Glassdoor has 550,609 interview questions and reports from Software interviews. Prepare for your interview. Get hired. Love your job.