Checking if a string contains all unique characters I am currently reviewing CTCI(Cracking the Coding Interview)
The question is asking me to implement an algorithm which checks whether the characters in a string are all unique however they do not want me to use any auxillary data structures
My Algorithm is relatively straight forward, Two nested loops one starting at 0(i)  and another at 1(i+1)
If the condition finds two characters that are equal then I print duplicate characters have been found.
 public static void checkUnique(String s)
{


    for(int i = 0; i&lt;s.length(); ++i)
    {
        for(int j = i +1; j&lt;s.length(); ++j)
        {
            if(s.charAt(i) == s.charAt(j))
            {
                System.out.println(&quot;Duplicates found&quot;);
            }
        }
    }


}

My question

Is this an optimal algorithm, my second approach was to sort, and find a  pair which contains the same characters.
Obviously a hashmap would be beneficial here, but questions does not really want me to use it.

I have refactored the code and hopefully now it is correct.
Is there any way of reducing it to an O(N) runtime. What if we keep track of the Unicode code's for each char character. I doubt O(N^2) is the best we can do here.
A way to optimize it would be to return as soon as you have found a duplicate, unless the question specifically asks you to list all duplicates.
You could refactor it to something like that:
public static boolean checkUnique(String s) {
    int len = s.length();
    for (int i = 0; i &lt; len; i++) {
        int c = s.codePointAt(i);
        int next = s.indexOf(c, i + 1);
        if (next &gt; i) {
             return false;
        }
    }
    return true;
}

It isn't more efficient as your solution, but I doubt there is an algorithm that can do it better.