Check to see if Two Nodes are Cousins

bool areCousins(Node *root, Node* a, Node* b) {
    if(level(root, a, 0) == level(root, b, 0) && !isSibling(root, a, b) {
        return true;
    } else {
        return false;
    }
}

results matching ""

    No results matching ""