Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> If it doesn't, then why not simply move the sort out of the loop?

Yup, they should definitely move the sort outside of the loop. Shifting is O(N) so overall complexity would be O(N^2) but they could avoid shifting by reverse-sorting outside the loop and then iterating backwards using pop()



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

Search: