You are viewing a single comment's thread. Return to all comments →
All tests passed...
public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int pairs = in.nextInt(); HashSet<String> set = new HashSet<>(); in.nextLine(); while(pairs-- > 0){ String left = in.next().trim(); String right = in.next().trim(); String pairLR = left + " " + right; String pairRL = right + " " + left; if(!set.contains(pairRL)) set.add(pairLR); System.out.println(set.size()); } in.close(); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Java Hashset
You are viewing a single comment's thread. Return to all comments →
All tests passed...