You are viewing a single comment's thread. Return to all comments →
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int t = s.nextInt();
String [] pair_left = new String[t];
String [] pair_right = new String[t];
for (int i = 0; i < t; i++) { pair_left[i] = s.next(); pair_right[i] = s.next(); } int unique=0; HashSet<String> hs = new HashSet<>(); for(int j=0;j<t;j++){ if(hs.add(pair_left[j]+" "+pair_right[j])==true){ unique++; } System.out.println(unique); } }
}
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 →
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int t = s.nextInt();
String [] pair_left = new String[t];
String [] pair_right = new String[t];
}