• + 1 comment

    Here is my code that it can pass 5 test cases. I'm really disappointed of this problem. As you can see the problem tell us that "That also implies (a, b) is not same as (b, a)". But when you code with that constraint you can't pass test case 5. This makes me watse of time. So after doing this problem i gain experience that after 30 minutes if you can't pass all test cases just go to disussions and see how people solve the problem.

    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();
            }
    
    //Write your code here
        Set<String> uniquePairs = new HashSet<>();
            for (int i = 0; i < t; i++) {
                String pair1 = pair_left[i] + " " + pair_right[i];
                String pair2 = pair_right[i] + " " + pair_left[i];
                if(!uniquePairs.contains(pair1) && !uniquePairs.contains(pair2)){
                    uniquePairs.add(pair1);
                }
                System.out.println(uniquePairs.size());
            }
        }
    }[](https://)
    
    • + 0 comments

      what is the solution though to pass test case 5?