Skip to content

Commit 38002f7

Browse files
committed
update readme
1 parent b30dda0 commit 38002f7

3 files changed

Lines changed: 32 additions & 4 deletions

File tree

‎Algorithm/README.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
1. [约瑟夫环]()
1+
1. [约瑟夫环](https://github.com/lambdaplus/python/blob/master/Algorithm/joseph-ring.py)
2+
2. [寻找两个链表的第一个交点](https://www.zybuluo.com/Scrazy/note/719335)
3+
3. [删除链表中的重复元素](https://www.zybuluo.com/Scrazy/note/720542)
4+
4. [数组中的数组成最小值](https://www.zybuluo.com/Scrazy/note/720582)
5+
5. [索引为index 的丑数](https://www.zybuluo.com/Scrazy/note/720587)

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
11. [新浪博客抓取及简单聚类](https://www.zybuluo.com/mdeditor#709348)
1414
12. [Python 算法教程 笔记](https://www.zybuluo.com/Scrazy/note/530998)
1515
13. [TCP简述](https://www.zybuluo.com/Scrazy/note/717147)
16+
14. [单例模式](https://www.zybuluo.com/Scrazy/note/719017)

‎binary_tree.md‎

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,18 +273,19 @@ s = Solution()
273273
t = s.reConstructBinaryTree(pre, tin)
274274
s.print_tree(t)
275275
```
276-
树的子结构
276+
### 树的子结构
277277

278278
```python
279+
求pRoot2 的子树是否为 pRoot2
279280
# -*- coding:utf-8 -*-
280281
# class TreeNode:
281282
# def __init__(self, x):
282283
# self.val = x
283284
# self.left = None
284285
# self.right = None
285286
class Solution:
286-
def is_subtree(self, t1, t2):
287-
if not t2:
287+
def is_subtree(self, t1, t2):
288+
if not t2: # t2 is None 其为子树
288289
return True
289290
if not t1:
290291
return False
@@ -304,4 +305,26 @@ class Solution:
304305
result = self.is_subtree(pRoot1.right, pRoot2)
305306
return result
306307
```
308+
### 对称二叉树
307309

310+
```
311+
# -*- coding:utf-8 -*-
312+
# class TreeNode:
313+
# def __init__(self, x):
314+
# self.val = x
315+
# self.left = None
316+
# self.right = None
317+
class Solution:
318+
319+
def isSymmetrical(self, pRoot):
320+
def is_same(p1, p2):
321+
if not (p1 or p2):
322+
return True
323+
elif p1 and p2 and p1.val == p2.val:
324+
return is_same(p1.left, p2.right) and is_same(p1.right, p2.left)
325+
return False
326+
327+
if not pRoot:
328+
return True
329+
return is_same(pRoot.left, pRoot.right)
330+
```

0 commit comments

Comments
 (0)