Created
March 20, 2014 22:40
-
-
Save rayjcwu/9675576 to your computer and use it in GitHub Desktop.
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
| public String uniqueChar(String str) { | |
| Set<Character> showed = new HashSet<Character>(); | |
| StringBuilder sb = new StringBuilder(); | |
| for (int i = 0; i < str.length(); ++i) { | |
| final char c = str.charAt(i); | |
| if (!showed.contains(c)) { | |
| showed.add(c); | |
| sb.append(c); | |
| } | |
| } | |
| return sb.toString(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment