classSolution { public: intmaxDepth(Node* root){ int depth = 0; queue<Node*> qe; if (root) qe.push(root); while (!qe.empty()) { int node_num = qe.size(); for (int i = 0; i < node_num; i++) { auto tmp = qe.front(); qe.pop();
for (int j = 0; j < tmp->children.size(); ++j) { if (tmp->children[j]) qe.push(tmp->children[j]); } } ++depth; }