Hacker News new | past | comments | ask | show | jobs | submit login

Sum the input list, sum the list of [1...n], subtract and voila!



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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: