Ubisoft Interview Question: Given numbers 1 to 100 in an ... | Glassdoor

Interview Question

Junior Software Developer Interview

Given numbers 1 to 100 in an array a random number was

  replaced with 0. Find the which number it was in constant time (100).
Answer

Interview Answer

2 Answers

1

easy
add all elements of array and store in a variable n
sum(100)-n is the answer

ABHINAV on Feb 10, 2013
0

Since sum of 1 to 100 is 5050, replaced number = 5050 - sum(array)

Anonymous on Jan 9, 2017

Add Answers or Comments

To comment on this, Sign In or Sign Up.