What does it mean: Submission Result: Runtime Error Last executed input: {-1}!


  • 1
    F

    UndirectedGraphNode getGraphNode(unordered_map<int, UndirectedGraphNode> collect, int label) {
    if (collect.find(label) == collect.end()) {
    UndirectedGraphNode * newNode = new UndirectedGraphNode(label);
    collect[label] = newNode;
    }
    return collect[label];
    }

    UndirectedGraphNode cloneGraph(UndirectedGraphNode node) {
    if (!node) {
    return NULL;
    }
    unordered_map<int, UndirectedGraphNode
    > collect;
    stack<UndirectedGraphNode
    > s;
    s.push(node);
    while (!s.empty()) {
    UndirectedGraphNode * original = s.top();
    s.pop();
    UndirectedGraphNode *graphNode = getGraphNode(collect, original->label);
    for (int i = 0; i < original->neighbors.size(); ++i) {
    graphNode->neighbors.push_back(getGraphNode(collect, original->neighbors[i]->label));
    }
    }
    return collect[node->label];
    }

    When I run test, it reported that:

    Submission Result: Runtime Error
    Last executed input: {-1}

    I haven't find any problem in my code, is there any?


Log in to reply
 

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