String Construction

  • + 0 comments

    Java Code using HashSet

    public static int stringConstruction(String s) {
        
            Set<Character> set = new HashSet<>();
            for (char c : s.toCharArray()) {
                set.add(c);
            }
            return set.size();
        }