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

With only one repeated number, you can sum the array and subtract 1+…+n to get the answer. Still an annoying trick you wouldn’t expect in an algorithm problem. Though the leetcode version also doesn’t require linear time, so I guess you could just iterate and compare in quadratic time to solve it?



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

Search: