To implement an algorithm to determine if a string contains all unique characters.
Input : s = “abcd”
“abcd” doesn’t contain any duplicates. Hence the output is True.
Input : s = “abbd”
“abbd” contains duplicates. Hence the output is False.
One solution is to create an array of boolean values, where the flag at the index i indicates whether character i in the alphabet is contained in the string. The second time you see this character you can immediately return false.
You can also return false if the string length exceeds the number of unique characters in the alphabet.