package hackerrank;

import java.util.Scanner;

/**
 * https://www.hackerrank.com/challenges/string-construction
 */
public class StringConstruction {
    private static int stringConstruction(String str) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            String str = in.next();
            System.out.println(stringConstruction(str));
        }
    }
}

package hackerrank;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * https://www.hackerrank.com/challenges/string-construction
 */
public class StringConstruction {
    private static int stringConstruction(String str) {
        int count = 0;
        Set<Character> set = new HashSet<>();
        for (int i = 0; i < str.length(); i++) {
            if (set.add(str.charAt(i))) {
                count++;
            }
        }
        return count;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for (int a0 = 0; a0 < n; a0++) {
            String s = in.next();
            System.out.println(stringConstruction(s));
        }
    }
}

Solve String Construction