4 ms·
I thought the trick with this one was to sum all the entries and subtract the sum of 0 to N-2. The remainder is the duplicate entry. It's just a trick though;
by Robin_Message 10y ago
I thought the trick with this one was to sum all the entries and subtract the sum of 0 to N-2. The remainder is the duplicate entry.
It's just a trick though; I don't think skill in coming up with these is particularly well-correlated with being a good programmer, and for that reason Google claims not to do teasers like this any more.
- gms7777 10y agoThat works in the case where there is exactly one duplicate entry. The question says there is at least one dup entry.
- serge2k 10y ago> for that reason Google claims not to do teasers like this any more. All google does is teasers like this.
- bdavisx 10y agoIf a company is relying on someone coming up with a trick answer, then they deserve the employees that they get.