Improvement article - "Check if a String Has All Unique Characters in Java"
This commit is contained in:
parthiv39731
2023-08-01 15:22:01 +05:30
committed by GitHub
parent 136ba8a382
commit 4401a6c258

View File

@@ -34,9 +34,11 @@ public class UniqueCharChecker {
char[] chars = str.toUpperCase().toCharArray();
Set <Character> set = new HashSet <>();
for (char c: chars) {
set.add(c);
if (!set.add(c)) {
return false;
}
}
return set.size() == str.length();
return true;
}
public static boolean useStreamCheck(String str) {