O(n) solution post sorting for input that doesn't have dupes.