You are viewing a single comment's thread. Return to all comments →
Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); HashSet<String> set = new HashSet<>(); IntStream.range(1, n+1).forEach(i -> { set.add(Stream.of(scanner.next(), scanner.next()) .sorted(String::compareTo) .collect(Collectors.joining(" "))); System.out.println(set.size()); }); scanner.close();
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Java Hashset
You are viewing a single comment's thread. Return to all comments →