# 剑指offer44 — 按之字形打印二叉树

## 代码

# -*- coding:utf-8 -*-
# class TreeNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None
class Solution:
def Print(self, pRoot):
# write code here
if pRoot == None:
return []
stack1 = [pRoot]
stack2 = []
ret = []
while stack1 or stack2:
if stack1:
tmpRet = []
while stack1:
tmpNode = stack1.pop()
tmpRet.append(tmpNode.val)
if tmpNode.left:
stack2.append(tmpNode.left)
if tmpNode.right:
stack2.append(tmpNode.right)
ret.append(tmpRet)
if stack2:
tmpRet = []
while stack2:
tmpNode = stack2.pop()
tmpRet.append(tmpNode.val)
if tmpNode.right:
stack1.append(tmpNode.right)
if tmpNode.left:
stack1.append(tmpNode.left)
ret.append(tmpRet)
return ret


12-26 1727

02-24 115

06-26 2968

02-18 242

07-19 603

08-13 72

06-15 14

07-14 91

08-07 122

05-05 431

04-28 27

03-28 231

07-03 52

05-15 136

07-17 205

07-19 1754

03-28 809

04-14 56万+

03-13 14万+

02-27 7万+

02-28 4万+

03-01 12万+

03-01 11万+

03-01 1万+

03-03 2万+

05-23 4019

03-04 12万+

03-04 3405

03-05 5万+

03-08 4万+

03-08 6万+

03-08 2万+

03-08 1万+

04-25 6万+

03-10 12万+

03-10 17万+

03-12 10万+

03-13 10万+

03-19 7万+

03-22 3万+

03-23 1万+

03-23 4万+

03-24 3万+

03-25 2万+

05-08 4万+

03-25 8万+

03-26 3万+

03-27 4万+

03-29 20万+

03-29 9万+

03-30 14万+

05-21 2939

05-25 5233

03-23 1万+

04-02 3万+

05-06 2万+

04-05 1万+

04-06 899

04-06 6万+

04-07 4万+

04-09 7万+

04-09 2万+

05-17 5343

04-09 4725

04-11 2万+

04-15 5万+

04-18 4万+

04-20 3万+

04-24 2万+

04-26 3682

04-30 7540

05-16 4万+

05-06 1万+

05-08 3万+

05-11 3万+

05-13 6770

05-13 9775

05-14 3680

05-14 6151

#### 微服务为什么一定要用docker？阿里架构师带你彻底了解docker

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客