News for hackers. Stuff that matters.
Re:Amazon’s Interview Questions And Why I Don’t Work At Amazon by XenithShade on Sunday October 20, 2013 @09:03PM (#6582474)
Closed form is ((1 + 250)* 250)/2

Once you know the actual sum, you can do it either: sum all, subtract total - sum. Or with data structures: it would be a variant of the "given an array find all pairs of numbers that add up to a sum". The benefit of using the data structure approach would be that you can now find x missing numbers in the range 1 - 250.

note* the closed form might have a off by one error

There are no comments on this comment yet.