I am working through the book \"Cracking the Coding Interview\" and I have come across questions here asking for answers, but I need help comparing my answer to the solution
This is the necessary correction to the book's code:
public static boolean checkForUnique(String str){ boolean containsUnique = false; for(char c : str.toCharArray()){ if(str.indexOf(c) == str.lastIndexOf(c)){ containsUnique = true; } else { return false; } } return containsUnique; }