Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8090352

Browse files
refactor for format
1 parent 9a95106 commit 8090352

File tree

1 file changed

+9
-3
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+9
-3
lines changed

src/main/java/com/fishercoder/solutions/_103.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ public class _103 {
3333
public List<List<Integer>> zigzagLevelOrder(TreeNode root) {
3434
Queue<TreeNode> q = new LinkedList();
3535
List<List<Integer>> levels = new ArrayList();
36-
if (root == null) return levels;
36+
if (root == null) {
37+
return levels;
38+
}
3739
q.offer(root);
3840
boolean forward = true;
3941
while (!q.isEmpty()) {
@@ -42,8 +44,12 @@ public List<List<Integer>> zigzagLevelOrder(TreeNode root) {
4244
for (int i = 0; i < size; i++) {
4345
TreeNode curr = q.poll();
4446
level.add(curr.val);
45-
if (curr.left != null) q.offer(curr.left);
46-
if (curr.right != null) q.offer(curr.right);
47+
if (curr.left != null) {
48+
q.offer(curr.left);
49+
}
50+
if (curr.right != null) {
51+
q.offer(curr.right);
52+
}
4753
}
4854
if (forward) {
4955
forward = false;

0 commit comments

Comments
 (0)