You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Given the root of a binary tree, return the zigzag level order traversal of its nodes' values. (i.e., from left to right, then right to left for the next level and alternate between).
3
+
4
+
5
+
6
+
// Example 1:
7
+
8
+
9
+
// Input: root = [3,9,20,null,null,15,7]
10
+
// Output: [[3],[20,9],[15,7]]
11
+
// Example 2:
12
+
13
+
// Input: root = [1]
14
+
// Output: [[1]]
15
+
// Example 3:
16
+
17
+
// Input: root = []
18
+
// Output: []
19
+
20
+
/**
21
+
* Definition for a binary tree node.
22
+
* public class TreeNode {
23
+
* public int val;
24
+
* public TreeNode left;
25
+
* public TreeNode right;
26
+
* public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) {
// Given the root of a binary tree, return the bottom-up level order traversal of its nodes' values. (i.e., from left to right, level by level from leaf to root).
4
+
5
+
6
+
7
+
// Example 1:
8
+
9
+
10
+
// Input: root = [3,9,20,null,null,15,7]
11
+
// Output: [[15,7],[9,20],[3]]
12
+
// Example 2:
13
+
14
+
// Input: root = [1]
15
+
// Output: [[1]]
16
+
// Example 3:
17
+
18
+
// Input: root = []
19
+
// Output: []
20
+
21
+
/**
22
+
* Definition for a binary tree node.
23
+
* public class TreeNode {
24
+
* public int val;
25
+
* public TreeNode left;
26
+
* public TreeNode right;
27
+
* public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) {
0 commit comments