4 ms·
Sum the input list, sum the list of [1...n], subtract and voila!
by sanedigital 4y ago
Sum the input list, sum the list of [1...n], subtract and voila!
- robbie-c 4y agoYeah, 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.
- deleted 4y ago[deleted]
- sanedigital 4y agoWhat things? I submitted it as an answer on Leetcode and it was accepted.