Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf81d026

Browse files
committed
2017 8.30
1 parent139b225 commitf81d026

File tree

1 file changed

+46
-29
lines changed

1 file changed

+46
-29
lines changed

‎Readme.md

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,35 +1188,6 @@ class Solution:
11881188
return head
11891189
```
11901190

1191-
```python
1192-
classListNode:
1193-
def__init__(self,x):
1194-
self.val= x
1195-
self.next=None
1196-
1197-
classnonrecurse(head):
1198-
if headisNoneor head.nextisNone:
1199-
return head
1200-
pre=None
1201-
cur= head
1202-
h= head
1203-
while cur:
1204-
h= cur
1205-
1206-
temp= cur.next
1207-
cur.next= pre
1208-
1209-
pre= cur
1210-
cur= temp
1211-
return h
1212-
1213-
1214-
```
1215-
1216-
思路:http://blog.csdn.net/feliciafay/article/details/6841115
1217-
方法:http://www.xuebuyuan.com/2066385.html?mobile=1
1218-
1219-
12201191
##7 创建字典的方法
12211192

12221193
###1 直接创建
@@ -1503,6 +1474,47 @@ if __name__ == '__main__':
15031474

15041475
深度遍历改变顺序就OK了
15051476

1477+
```python
1478+
1479+
#coding:utf-8
1480+
#二叉树的遍历
1481+
#简单的二叉树节点类
1482+
classNode(object):
1483+
def__init__(self,value,left,right):
1484+
self.value= value
1485+
self.left= left
1486+
self.right= right
1487+
1488+
#中序遍历:遍历左子树,访问当前节点,遍历右子树
1489+
1490+
defmid_travelsal(root):
1491+
if root.leftisNone:
1492+
mid_travelsal(root.left)
1493+
#访问当前节点
1494+
print(root.value)
1495+
if root.rightisnotNone:
1496+
mid_travelsal(root.right)
1497+
1498+
#前序遍历:访问当前节点,遍历左子树,遍历右子树
1499+
1500+
defpre_travelsal(root):
1501+
print (root.value)
1502+
if root.leftisnotNone:
1503+
pre_travelsal(root.left)
1504+
if root.rightisnotNone:
1505+
pre_travelsal(root.right)
1506+
1507+
#后续遍历:遍历左子树,遍历右子树,访问当前节点
1508+
1509+
defpost_trvelsal(root):
1510+
if root.leftisnotNone:
1511+
post_trvelsal(root.left)
1512+
if root.rightisnotNone:
1513+
post_trvelsal(root.right)
1514+
print (root.value)
1515+
1516+
```
1517+
15061518
##18 求最大树深
15071519

15081520
```python
@@ -1573,6 +1585,11 @@ while root:
15731585
root= root.next
15741586
```
15751587

1588+
思路:http://blog.csdn.net/feliciafay/article/details/6841115
1589+
1590+
方法:http://www.xuebuyuan.com/2066385.html?mobile=1
1591+
1592+
15761593
##22 两个字符串是否是变位词
15771594

15781595
```python

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp