• + 1 comment
    import java.io.*;
    import java.util.*;
    
    public class Solution {
    
        public static void main(String[] args) {
            Scanner scan = new Scanner(System.in);
            
            int n = scan.nextInt();
            scan.nextLine();
            
            HashSet<String> pairs = new HashSet<>();
            int numUnique = 0;
            
            for (int i = 0; i < n; i++) {
                String line = scan.nextLine();
                if (!pairs.contains(line)) {
                    numUnique++;
                    pairs.add(line);
                }
                System.out.println(numUnique);
            }        
            
            scan.close();
        }
    }
    

    Hi guys. This is my solution but it is failing on the 5th test case. Could anyone tell me where I am going wrong?