Skip to content

Commit ff14185

Browse files
author
cclauss
committed
print() is a function in Python 3
1 parent 9109012 commit ff14185

169 files changed

Lines changed: 449 additions & 279 deletions

File tree

Some content is hidden

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

Python/candy.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Time: O(n)
23
# Space: O(n)
34
#
@@ -11,6 +12,7 @@
1112
#
1213

1314
import operator
15+
from functools import reduce
1416

1517
class Solution:
1618
# @param ratings, a list of integer
@@ -29,5 +31,5 @@ def candy(self, ratings):
2931

3032
if __name__ == "__main__":
3133
result = Solution().candy([1, 2, 3, 2, 3, 5, 2, 5])
32-
print result
34+
print(result)
3335

Python/climbing-stairs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Time: O(n)
23
# Space: O(1)
34
#
@@ -29,4 +30,4 @@ def climbStairs1(self, n):
2930

3031
if __name__ == "__main__":
3132
result = Solution().climbStairs(2)
32-
print result
33+
print(result)

Python/combination-sum-ii.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Time: O(k * C(n, k))
23
# Space: O(k)
34
#
@@ -42,4 +43,4 @@ def combinationSumRecu(self, candidates, result, start, intermediate, target):
4243
if __name__ == "__main__":
4344
candidates, target = [10, 1, 2, 7, 6, 1, 5], 8
4445
result = Solution().combinationSum2(candidates, target)
45-
print result
46+
print(result)

Python/combination-sum.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Time: O(k * n^k)
23
# Space: O(k)
34
#
@@ -37,4 +38,4 @@ def combinationSumRecu(self, candidates, result, start, intermediate, target):
3738
if __name__ == "__main__":
3839
candidates, target = [2, 3, 6, 7], 7
3940
result = Solution().combinationSum(candidates, target)
40-
print result
41+
print(result)

Python/combinations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Time: O(k * C(n, k))
23
# Space: O(k)
34

@@ -61,4 +62,4 @@ def combineDFS(n, start, intermediate, k, result):
6162

6263
if __name__ == "__main__":
6364
result = Solution().combine(4, 2)
64-
print result
65+
print(result)

Python/compare-version-numbers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Time: O(n)
23
# Space: O(1)
34

@@ -99,6 +100,6 @@ def compareVersion4(self, version1, version2):
99100

100101

101102
if __name__ == "__main__":
102-
print Solution().compareVersion("21.0", "121.1.0")
103-
print Solution().compareVersion("01", "1")
104-
print Solution().compareVersion("1", "1.0")
103+
print(Solution().compareVersion("21.0", "121.1.0"))
104+
print(Solution().compareVersion("01", "1"))
105+
print(Solution().compareVersion("1", "1.0"))

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Time: O(n)
23
# Space: O(n)
34
#
@@ -37,6 +38,6 @@ def buildTreeRecu(self, lookup, postorder, inorder, post_end, in_start, in_end):
3738
inorder = [2, 1, 3]
3839
postorder = [2, 3, 1]
3940
result = Solution().buildTree(inorder, postorder)
40-
print result.val
41-
print result.left.val
42-
print result.right.val
41+
print(result.val)
42+
print(result.left.val)
43+
print(result.right.val)

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Time: O(n)
23
# Space: O(n)
34
#
@@ -37,6 +38,6 @@ def buildTreeRecu(self, lookup, preorder, inorder, pre_start, in_start, in_end):
3738
preorder = [1, 2, 3]
3839
inorder = [2, 1, 3]
3940
result = Solution().buildTree(preorder, inorder)
40-
print result.val
41-
print result.left.val
42-
print result.right.val
41+
print(result.val)
42+
print(result.left.val)
43+
print(result.right.val)

Python/container-with-most-water.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Time: O(n)
23
# Space: O(1)
34
#
@@ -26,4 +27,4 @@ def maxArea(self, height):
2627
if __name__ == "__main__":
2728
height = [1, 2, 3, 4, 3, 2, 1, 5]
2829
result = Solution().maxArea(height)
29-
print result
30+
print(result)

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Time: O(n)
23
# Space: O(logn)
34
#
@@ -49,6 +50,6 @@ def perfect_tree_pivot(self, n):
4950
if __name__ == "__main__":
5051
num = [1, 2, 3]
5152
result = Solution().sortedArrayToBST(num)
52-
print result.val
53-
print result.left.val
54-
print result.right.val
53+
print(result.val)
54+
print(result.left.val)
55+
print(result.right.val)

0 commit comments

Comments
 (0)