Skip to content

Instantly share code, notes, and snippets.

@larry-liu
Last active August 29, 2015 14:02
Show Gist options
  • Save larry-liu/e2cc893aa60b01545c21 to your computer and use it in GitHub Desktop.
Save larry-liu/e2cc893aa60b01545c21 to your computer and use it in GitHub Desktop.
CC1.1
import java.util.HashSet;
import java.util.Set;
public class UniqueChar {
public static boolean check(String s) {
Set<Character> hashset = new HashSet<Character>();
for (int i = 0; i < s.length(); i++) {
if (hashset.contains(s.charAt(i)))
return false;
else
hashset.add(s.charAt(i));
}
return true;
}
public static void main(String[] args) {
String s = "this is what i need";
System.out.println(check(s));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment