Something Wrong with the TestCases


  • 0
    P

    On submitting the solution, wrong answer is coming for
    [[3,4],[2,3],[1,2]]
    expected: [2,3]
    output: []

    Although, on running same test case as custom test case:
    [[3,4],[2,3],[1,2]]
    expected: []
    output: []

    And NULL should be the right answer, because input is already a tree, no redundant edge.

    class Solution {
    public:
        int findParent(vector<int> & parent, int node)
        {
            int curr = node;
            while(parent[curr] != curr)
            {
                curr = parent[curr];
            }
            return curr;
        }
        vector<int> findRedundantConnection(vector<vector<int>>& edges) {
            vector<int> parents(2000, 0);
            vector<int> res;
            for(int i=0 ;i<2000; i++) parents[i] = i;
            int esize = edges.size();
            for(int i=0; i<esize; i++)
            {
                if(findParent(parents, edges[i][0]) != findParent(parents, edges[i][1]))
                {
                     parents[edges[i][1]] = edges[i][0]; 
                }else{
                    return edges[i];
                }
            }
            return res;
        }
    };
    

  • 0
    Y

    Met the same problem


  • 0
    M

    Nothing wrong with the test case. Something is wrong with their online judge engine. Now no solution can be accepted, you can try other's accepted solution. They messed it up.
    Wasted me 2 hours.


  • 0
    R

    this is my reslut after a submission

    Input:
    [[3,4],[2,3],[1,2]]
    Output:
    [3,2]
    Expected:
    [2,3]
    

    When I only return edges from the input array.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.