uniqueCharacters() function that determines if any given string has all unique characters (i.e. no character in the string is duplicated). If the string has all unique characters, the function should return
true. If the string does not have all unique characters, return
uniqueCharacters("apple") should return
This challenge and variations of it were reported to have been asked at interviews with Google. If you’ve covered the material in Pass the Technical Interview with Java or an equivalent, you should be able to solve this challenge. If you have trouble, try refreshing your knowledge there first.
Note that the function should also return
false if it is called with an empty string (
"") — there cannot be unique characters if there are no characters at all.