Spoiler alert, don't read this if you haven't completed the activity!
Many of the solutions for this activity (including my own) use sort in the canonical method, which works well but does not have an optimal time complexity. I think it would be fun if there was an extra credit part of this where you would need to at least be as good as O(n).