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

Commit 6b77d38

Browse files
committed
md
1 parent 191ebb3 commit 6b77d38

File tree

3 files changed

+81
-13
lines changed

3 files changed

+81
-13
lines changed

‎README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,20 @@
105105
|112|[Path Sum](https://leetcode.com/problems/path-sum/#/description)| [Python [Yu]](./tree/Yu/112_hasPathSum.py) | _O(N)_| _O(h)_ | Easy | |[中文讲解](https://www.youtube.com/watch?v=LgtcGjIuE18&feature=youtu.be)|
106106
|100|[Same Tree](https://leetcode.com/problems/same-tree/)| [Python [Yu]](./tree/Yu/100_isSameTree.py) | _O(N)_| _O(1)_ | Easy |||
107107
|101|[Symmetric Tree](https://leetcode.com/problems/symmetric-tree/#/description)| [Python [Yu]](./tree/Yu/101_symmetricTree.py)| _O(N)_| _O(1)_ | Easy ||[:tv:](https://youtu.be/3Gl4F29LVpQ)|
108-
|104|[Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree/)| [Python](./tree/Yu/104_maxDepth.py) | _O(N)_| _O(1)_ | Easy |||
109-
|108|[Convert Sorted Array to Binary Search Tree](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/#/solutions)| [Python [Yu]](./tree/Yu/108.py) | _O(N)_| _O(N)_ | Easy ||[:tv:](https://www.youtube.com/watch?v=lBrb4fXPcMM)|
110-
|111|[Minimum Depth of Binary Tree](https://leetcode.com/problems/minimum-depth-of-binary-tree/#/description)| [Python [Yu]](https://github.com/yuzhoujr/LeetCode/blob/master/tree/Yu/111_minDepth.py)| _O(N)_| _O(1)_ | Easy |||
111-
|235|[Lowest Common Ancestor of a Binary Search Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/#/description)| [Python](./tree/Yu/235_lca_bst.py) | _O(N)_| _O(1)_ | Easy |||
112-
|226|[Invert Binary Tree](https://leetcode.com/problems/invert-binary-tree/#/description)| [Python [Yu]](./tree/Yu/226.py) | _O(N)_| _O(1)_ | Easy ||[:tv:](https://youtu.be/oiX3mqcAK0s)|
113-
|543|[Diameter of Binary Tree](https://leetcode.com/problems/diameter-of-binary-tree/#/description)| [Python [Yu]](./tree/Yu/543.py) | _O(N)_| _O(h)_ | Easy ||[:tv:](https://www.youtube.com/watch?v=0VnOfu2pYTo)|
114-
|501|[Find Mode in Binary Search Tree](https://leetcode.com/problems/find-mode-in-binary-search-tree/#/description)| [Python [Yu]](./tree/Yu/501.py) | _O(N)_| _O(N)_ | Easy ||[:tv:](https://youtu.be/v4F4x_uwMb8)|
115-
|257|[Binary Tree Paths](https://leetcode.com/problems/binary-tree-paths/#/description)| [Python [Yu]](./tree/Yu/257.py) | _O(N)_| _O(N)_ | Easy ||[:tv:](https://youtu.be/Zr_7qq2f16k)|
116-
|572|[Subtree of Another Tree](https://leetcode.com/problems/subtree-of-another-tree/#/description)| [Python [Yu]](./tree/Yu/572.py) | _O(S*T)_| _O(1)_ | Easy ||[:tv:](https://youtu.be/v4F4x_uwMb8)|
108+
|104|[Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree/)| [Python](./tree/Yu/104_maxDepth.py) | _O(N)_| _O(1)_ | ||
109+
|108|[Convert Sorted Array to Binary Search Tree](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/#/solutions)| [Python [Yu]](./tree/Yu/108.py) | _O(N)_| _O(N)_ | |[:tv:](https://www.youtube.com/watch?v=lBrb4fXPcMM)|
110+
|111|[Minimum Depth of Binary Tree](https://leetcode.com/problems/minimum-depth-of-binary-tree/#/description)| [Python [Yu]](https://github.com/yuzhoujr/LeetCode/blob/master/tree/Yu/111_minDepth.py)| _O(N)_| _O(1)_ |||
111+
|235|[Lowest Common Ancestor of a Binary Search Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/#/description)| [Python](./tree/Yu/235_lca_bst.py) | _O(N)_| _O(1)_ | ||
112+
|226|[Invert Binary Tree](https://leetcode.com/problems/invert-binary-tree/#/description)| [Python [Yu]](./tree/Yu/226.py) | _O(N)_| _O(1)_ | |[:tv:](https://youtu.be/oiX3mqcAK0s)|
113+
|543|[Diameter of Binary Tree](https://leetcode.com/problems/diameter-of-binary-tree/#/description)| [Python [Yu]](./tree/Yu/543.py) | _O(N)_| _O(h)_ | |[:tv:](https://www.youtube.com/watch?v=0VnOfu2pYTo)|
114+
|501|[Find Mode in Binary Search Tree](https://leetcode.com/problems/find-mode-in-binary-search-tree/#/description)| [Python [Yu]](./tree/Yu/501.py) | _O(N)_| _O(N)_ | |[:tv:](https://youtu.be/v4F4x_uwMb8)|
115+
|257|[Binary Tree Paths](https://leetcode.com/problems/binary-tree-paths/#/description)| [Python [Yu]](./tree/Yu/257.py) | _O(N)_| _O(N)_ | |[:tv:](https://youtu.be/Zr_7qq2f16k)|
116+
|572|[Subtree of Another Tree](https://leetcode.com/problems/subtree-of-another-tree/#/description)| [Python [Yu]](./tree/Yu/572.py) | _O(S*T)_| _O(1)_ | |[:tv:](https://youtu.be/v4F4x_uwMb8)|
117117
|437|[Path Sum III](https://leetcode.com/problems/path-sum-iii/#/description)| [Python [Yu]](./tree/Yu/437.py) | _O(N^2)_| _O(1)_ | Easy | |[:tv:](https://www.youtube.com/watch?v=NTyOEYYyv-o)|
118-
|404|[Sum of Left Leaves](https://leetcode.com/problems/sum-of-left-leaves/#/description)| [Python [Yu]](./tree/Yu/404_sum_of_Left_Leaves.py) | _O(N)_| _O(1)_ | Easy ||[:tv:](https://youtu.be/pH-KxPcBF_4)|
119-
|270|[Closest Binary Search Tree Value](https://leetcode.com/problems/closest-binary-search-tree-value/#/description)| [Python [Yu]](./tree/Yu/270.py)| _O(N)_| _O(1)_ | Easy ||[:tv:](https://youtu.be/RwvQyKJxHZk)|
120-
|563|[Binary Tree Tilt](https://leetcode.com/problems/binary-tree-tilt/#/description)| [Python [Yu]](./tree/Yu/563.py) | _O(N)_| _O(1)_ | Easy ||[:tv:](https://youtu.be/47FQVP4ynk0)|
121-
|538|[Convert BST to Greater Tree](https://leetcode.com/problems/convert-bst-to-greater-tree/#/description)| [Python [Yu]](./tree/Yu/538.py) | _O(N)_| _O(1)_ | Easy ||[:tv:](https://youtu.be/YoEPWtXmkD4)|
118+
|404|[Sum of Left Leaves](https://leetcode.com/problems/sum-of-left-leaves/#/description)| [Python [Yu]](./tree/Yu/404_sum_of_Left_Leaves.py) | _O(N)_| _O(1)_ ||[:tv:](https://youtu.be/pH-KxPcBF_4)|
119+
|270|[Closest Binary Search Tree Value](https://leetcode.com/problems/closest-binary-search-tree-value/#/description)| [Python [Yu]](./tree/Yu/270.py)| _O(N)_| _O(1)_ ||[:tv:](https://youtu.be/RwvQyKJxHZk)|
120+
|563|[Binary Tree Tilt](https://leetcode.com/problems/binary-tree-tilt/#/description)| [Python [Yu]](./tree/Yu/563.py) | _O(N)_| _O(1)_ | |[:tv:](https://youtu.be/47FQVP4ynk0)|
121+
|538|[Convert BST to Greater Tree](https://leetcode.com/problems/convert-bst-to-greater-tree/#/description)| [Python [Yu]](./tree/Yu/538.py) | _O(N)_| _O(1)_ | |[:tv:](https://youtu.be/YoEPWtXmkD4)|
122122

123123

124124
## Tree Medium

‎array/242.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
# HashTable方法1
3+
def isAnagram1(self, s, t):
4+
hash1 = {}
5+
hash2 = {}
6+
7+
for char in s:
8+
if char in hash1:
9+
hash1[char] += 1
10+
else:
11+
hash1[char] = 1
12+
13+
for char in t:
14+
if char in hash2:
15+
hash2[char] += 1
16+
else:
17+
hash2[char] = 1
18+
19+
return hash1 == hash2
20+
21+
# HashTable方法2
22+
def isAnagram2(self, s, t):
23+
hash1 = {}
24+
hash2 = {}
25+
26+
for char in s:
27+
hash1[char] = hash1.get(char, 0 ) + 1
28+
for char in t:
29+
hash2[char] = hash2.get(char, 0) + 1
30+
31+
return hash1 == hash2
32+
33+
# HashTable方法3 利用Unicode,创建2个 Fixed Size Array
34+
def isAnagram3(self, s, t):
35+
"""
36+
:type s: str
37+
:type t: str
38+
:rtype: bool
39+
"""
40+
hash1 = [0]*26
41+
hash2 = [0]*26
42+
43+
for char in s:
44+
hash1[ord(char) - ord('a')] += 1
45+
for char in t:
46+
hash2[ord(char) - ord('a')] += 1
47+
48+
return hash1 == hash2
49+
50+
51+
# HashTable方法4 利用Unicode,创建1个 Fixed Size Array
52+
def isAnagram4(self, s, t):
53+
"""
54+
:type s: str
55+
:type t: str
56+
:rtype: bool
57+
"""
58+
arr = [0]*26
59+
60+
for char in s:
61+
arr[ord(char) - ord('a')] += 1
62+
for char in t:
63+
arr[ord(char) - ord('a')] -= 1
64+
65+
for num in arr:
66+
if num is not 0:
67+
return False
68+
return True

‎checklist.md

Whitespace-only changes.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /