How to find a given String have all Unique character.
SOURCE : StringUniqueChar.javapublic class StringUniqueChar { public static boolean isbool(String s) { boolean[] char_set = new boolean[256]; for (int i = 0; i < s.length(); i++) { int val = s.charAt(i); if (char_set[val]) { return false; } char_set[val] = true; } return true; } public static void main(String[] args) { String s = "this"; isbool(s); System.out.println(isbool(s)); }}INPUTString s = "this"OUTPUT
true

0 comments :
Post a Comment