Input Format

In the first line, there will be an integer  denoting number of pairs. Each of the next  lines will contain two strings seperated by a single space.

Constraints:

• Length of each string is atmost  and will consist lower case letters only.

Output Format

Print  lines. In the  line, print number of unique pairs you have after taking  pair as input.

# Java HashSet problem solution | HackerRank

HashSet<String> myhash = new HashSet<String>();
for (int i = 0; i < t; i++) {
System.out.println(myhash.size());
}

## Proper code program

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();
}

HashSet<String> pairs = new HashSet<String>(t);

for(int i = 0; i < t; i++)
{
pairs.add("(" + pair_left[i] + ", " + pair_right[i] + ")" );
System.out.println(pairs.size());
}
}
}