Click Here to go back to the homepage.

I've Been Everywhere, Man Solution:


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

public class Kattis {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int cases = sc.nextInt();
        for(int i = 0; i < cases; i++){
            HashSet<String> set = new HashSet<>();
            int cities = sc.nextInt();
            sc.nextLine();
            for(int j = 0; j < cities; j++)
                set.add(sc.nextLine());
            System.out.println(set.size());
        }
    }
}