diff options
Diffstat (limited to 'other/n_ary_tree_traverse.cpp')
-rw-r--r-- | other/n_ary_tree_traverse.cpp | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/other/n_ary_tree_traverse.cpp b/other/n_ary_tree_traverse.cpp deleted file mode 100644 index 9c89682..0000000 --- a/other/n_ary_tree_traverse.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "leetcode.h" - -class Solution { -public: - vvd levelOrder(Node *root) { - vvd ans; - if (!root) - return ans; - queue<Node *> q; - q.push(root); - while (!q.empty()) { - int n = q.size(); - vector<int> v; - while (n--) { - auto curr = q.front(); - q.pop(); - v.push_back(curr->val); - for (auto it : curr->children) - q.push(it); - } - ans.push_back(v); - } - return ans; - } -}; |