标签:solution turn node style tco return max clear back
class Solution { public: int maxDepth(Node* root) { int depth = 0; if (root != NULL) { queue<Node> Q; Q.push(Node(root->val, root->children)); while (!Q.empty()) { depth++;//层数自增 vector<Node> N; N.clear(); while (!Q.empty()) { Node livenode; livenode = Q.front(); Q.pop(); for (auto n : livenode.children) { N.push_back(Node(n->val, n->children)); } } for (auto n : N) { Q.push(Node(n.val, n.children)); } } } return depth; } };
标签:solution turn node style tco return max clear back
原文地址:https://www.cnblogs.com/asenyang/p/9703558.html