Difficult:Medium
題目
Given the root of a binary tree, return the level order traversal of its nodes’ values. (i.e., from left to right, level by level).
翻譯
給定二叉樹的根,返回其節點值的級別順序遍歷。 (即從左到右,逐級)。
範例
Example 1:
1 | Input: root = [3,9,20,null,null,15,7] |
Example 2:
1 | Input: root = [1] |
Example 3:
1 | Input: root = [] |
解題思路
1.利用遞迴搜尋
2.依層級加入陣列裡面
Solution
1 | var levelOrder = function (root) { |