Last active
August 29, 2015 14:02
-
-
Save larry-liu/e2cc893aa60b01545c21 to your computer and use it in GitHub Desktop.
CC1.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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