Remix.run Logo
▲ gjulianm 23 minutes ago

[SPOILERS!]

The O(n log n) solution seems to me like the trivial/straightforward one: count occurrences, then sort the pairs based on the count. Not sure how to get the O(n^2) without trying specifically to do so (like implementing a sort algorithm from scratch and making it quadratic)