(String str)
| 3 | public class Question { |
| 4 | |
| 5 | public static boolean isUniqueChars(String str) { |
| 6 | if (str.length() > 128) { |
| 7 | return false; |
| 8 | } |
| 9 | int checker = 0; |
| 10 | for (int i = 0; i < str.length(); i++) { |
| 11 | int val = str.charAt(i) - 'a'; |
| 12 | if ((checker & (1 << val)) > 0) return false; |
| 13 | checker |= (1 << val); |
| 14 | } |
| 15 | return true; |
| 16 | } |
| 17 | |
| 18 | public static boolean isUniqueChars2(String str) { |
| 19 | if (str.length() > 128) { |