Sort by

recency

|

401 Discussions

|

  • + 0 comments

    PASSES ALL 6 TESTCASES

    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();
        }
    
    Set<String> set = new HashSet<>();
    for (int i = 0; i < t; i++) {
        String key = ( pair_left[i].compareTo(pair_right[i]) <= 0) ? ( pair_left[i]+ " " + pair_right[i]) : (pair_right[i] + " " +  pair_left[i]);
        set.add(key);
        System.out.println(set.size());
    }
    

    } }

  • + 1 comment

    The issue with test case 6 is how the problem is formulated:

    The original problem statement says that order matters, but test case 6 behaves as if order does not matter.

    public class Solution {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        Set<String> set = new HashSet<>();
        for (int i = 0; i < t; i++) {
            String a = sc.next();
            String b = sc.next();
            String key = (a.compareTo(b) <= 0) ? (a + " " + b) : (b + " " + a);
            set.add(key);
            System.out.println(set.size());
        }
    }
    

    }

  • + 0 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();
        }
        HashSet<String> set = new HashSet<String>();
        for(int i=0; i<t; i++){
            String pair = pair_left[i] + " " + pair_right[i];
            set.add(pair);
            System.out.println(set.size());
        }
    
    
    
    }
    

    }

  • + 0 comments

    Test Case 5 is wrong as the expected output parsed incorrectly. e.g. around line 192 and 193 fh kg ni aa the test case treated it is the same as line 177 kg ni Please fix it. Thanks.

  • + 0 comments

    The testcase expected output provided for testcase 5 is wrong according to my findings, i have cross verified the outcome using eclipse to understand the difference.