Re:Codility - Automated tests of programming skills
by Estragon on Friday January 08, 2010 @12:10PM
(#1039916)
I'm pretty sure you have to iterate over it at least twice. I guess the specification is implicit in that.
[ Parent
| on HN ]
Re:Codility - Automated tests of programming skills
by anc2020 on Friday January 08, 2010 @03:13PM
(#1040309)
The best case possible is to iterate the list once - you sum the list from left to right holding cumulative answers and if the final sum is zero, that index is a valid answer.
The worst case of the best algorithm is to iterate twice - firstly as above, and then again in the opposite direction, comparing values from the first iteration.