Sort by

recency

|

422 Discussions

|

  • + 1 comment

    That also implies (a,b) is not same as (b,a).

    Test 5 only works if you disregard this and do the opposite.

  • + 1 comment
        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

    Test case 5th is incorrect: - Duplicate 191 / 259 ...

  • + 1 comment

    Test case 5 says there are 975 unique strings. I copied the data into Excel and ran this macro: =COUNTA(UNIQUE(D1:D1000)) The macro counted 990 unique strings.

    I also ran the code in my IDE and it reported 990 unique strings, verifying Excel's findings.

    It looks like this has been a known problem for a long time. I guess no one at HackerRank monitors this chat channel.

    UPDATE: I copy/pasted the code from the Editorial tab. It also failed on test case 5.

  • + 0 comments

    It seems that the test #5 is not counting the pair on line 192 because it was added before but swapped. I guess that's an error on testing...