Recently I came across a problem that asks to find out the non-unique characters in a string without any additional buffer. I interpreted this problem to be an in-place sort of the characters in the string and then iterating through it in order to track down the non-unique characters.
Another solution that can have O(1) space and O(n^2) run-time is having two 'for' loops going over the string to track down any pairs of characters that are common.
What I need is to sort the string in atleast O(nlogn) time with O(1) space.
Is there a simple/elegant way to do an in-place sort of characters in O(nlgn) with O(1) space?