Solution for unique chars in string and counting sort