Skip to content

Commit cc2703d

Browse files
committed
update
1 parent 25048ba commit cc2703d

File tree

166 files changed

+0
-1049
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+0
-1049
lines changed

Python/candy.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import print_function
21
# Time: O(n)
32
# Space: O(n)
43

@@ -20,8 +19,3 @@ def candy(self, ratings):
2019

2120
return reduce(operator.add, candies)
2221

23-
if __name__ == "__main__":
24-
result = Solution().candy([1, 2, 3, 2, 3, 5, 2, 5])
25-
print(result)
26-
27-

Python/climbing-stairs.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import print_function
21
# Time: O(n)
32
# Space: O(1)
43

@@ -22,7 +21,3 @@ def climbStairs1(self, n):
2221
return 2
2322
return self.climbStairs(n - 1) + self.climbStairs(n - 2)
2423

25-
if __name__ == "__main__":
26-
result = Solution().climbStairs(2)
27-
print(result)
28-

Python/combination-sum-ii.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import print_function
21
# Time: O(k * C(n, k))
32
# Space: O(k)
43

@@ -23,8 +22,3 @@ def combinationSumRecu(self, candidates, result, start, intermediate, target):
2322
prev = candidates[start]
2423
start += 1
2524

26-
if __name__ == "__main__":
27-
candidates, target = [10, 1, 2, 7, 6, 1, 5], 8
28-
result = Solution().combinationSum2(candidates, target)
29-
print(result)
30-

Python/combination-sum.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import print_function
21
# Time: O(k * n^k)
32
# Space: O(k)
43

@@ -20,8 +19,3 @@ def combinationSumRecu(self, candidates, result, start, intermediate, target):
2019
intermediate.pop()
2120
start += 1
2221

23-
if __name__ == "__main__":
24-
candidates, target = [2, 3, 6, 7], 7
25-
result = Solution().combinationSum(candidates, target)
26-
print(result)
27-

Python/combinations.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import print_function
21
# Time: O(k * C(n, k))
32
# Space: O(k)
43

@@ -46,7 +45,3 @@ def combineDFS(n, start, intermediate, k, result):
4645
return result
4746

4847

49-
if __name__ == "__main__":
50-
result = Solution().combine(4, 2)
51-
print(result)
52-

Python/compare-version-numbers.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import print_function
21
# Time: O(n)
32
# Space: O(1)
43

@@ -83,8 +82,3 @@ def compareVersion4(self, version1, version2):
8382
return cmp(int(main1), int(main2)) or len(rest1 + rest2) and self.compareVersion4(rest1, rest2)
8483

8584

86-
if __name__ == "__main__":
87-
print(Solution().compareVersion("21.0", "121.1.0"))
88-
print(Solution().compareVersion("01", "1"))
89-
print(Solution().compareVersion("1", "1.0"))
90-

Python/construct-binary-tree-from-inorder-and-postorder-traversal.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import print_function
21
# Time: O(n)
32
# Space: O(n)
43

@@ -27,11 +26,3 @@ def buildTreeRecu(self, lookup, postorder, inorder, post_end, in_start, in_end):
2726
node.right = self.buildTreeRecu(lookup, postorder, inorder, post_end - 1, i + 1, in_end)
2827
return node
2928

30-
if __name__ == "__main__":
31-
inorder = [2, 1, 3]
32-
postorder = [2, 3, 1]
33-
result = Solution().buildTree(inorder, postorder)
34-
print(result.val)
35-
print(result.left.val)
36-
print(result.right.val)
37-

Python/construct-binary-tree-from-preorder-and-inorder-traversal.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import print_function
21
# Time: O(n)
32
# Space: O(n)
43

@@ -27,11 +26,3 @@ def buildTreeRecu(self, lookup, preorder, inorder, pre_start, in_start, in_end):
2726
node.right = self.buildTreeRecu(lookup, preorder, inorder, pre_start + 1 + i - in_start, i + 1, in_end)
2827
return node
2928

30-
if __name__ == "__main__":
31-
preorder = [1, 2, 3]
32-
inorder = [2, 1, 3]
33-
result = Solution().buildTree(preorder, inorder)
34-
print(result.val)
35-
print(result.left.val)
36-
print(result.right.val)
37-

Python/container-with-most-water.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import print_function
21
# Time: O(n)
32
# Space: O(1)
43

@@ -14,8 +13,3 @@ def maxArea(self, height):
1413
j -= 1
1514
return max_area
1615

17-
if __name__ == "__main__":
18-
height = [1, 2, 3, 4, 3, 2, 1, 5]
19-
result = Solution().maxArea(height)
20-
print(result)
21-

Python/convert-sorted-array-to-binary-search-tree.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import print_function
21
# Time: O(n)
32
# Space: O(logn)
43

@@ -43,10 +42,3 @@ def perfect_tree_pivot(self, n):
4342
# has more nodes and the right subtree is perfect.
4443

4544

46-
if __name__ == "__main__":
47-
num = [1, 2, 3]
48-
result = Solution().sortedArrayToBST(num)
49-
print(result.val)
50-
print(result.left.val)
51-
print(result.right.val)
52-

0 commit comments

Comments
 (0)