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

[deleted]



If the largest number in the array start at index 0, then in the first sweep `n-sweep_number=n-1` "maybe-swaps" turn into `n-1` swaps, each moving the largest number one spot to the right. So it ends in position `n-1`, which is exactly where it belongs.




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

Search: