Hacker News new | ask | show | jobs
by sanedigital 1406 days ago
Sum the input list, sum the list of [1...n], subtract and voila!
1 comments

Yeah, sadly you're not guaranteed some of the things that are needed for this to work. I defo believe the story that it took Knuth a day to figure this out, although when you see the answer it's pretty easy to understand.
What things? I submitted it as an answer on Leetcode and it was accepted.