Skip to content

Commit 7497acc

Browse files
committed
Update paint-house.py
1 parent 558e613 commit 7497acc

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Diff for: Python/paint-house.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Time: O(n)
22
# Space: O(1)
33

4-
class Solution:
5-
# @param {integer[][]} costs
6-
# @return {integer}
4+
class Solution(object):
75
def minCost(self, costs):
6+
"""
7+
:type costs: List[List[int]]
8+
:rtype: int
9+
"""
810
if not costs:
911
return 0
1012

@@ -19,14 +21,16 @@ def minCost(self, costs):
1921
min_cost[i % 2][2] = costs[i][2] + \
2022
min(min_cost[(i - 1) % 2][0], min_cost[(i - 1) % 2][1])
2123

22-
return min(min_cost[(n - 1) % 2][0], min_cost[(n - 1) % 2][1], min_cost[(n - 1) % 2][2])
24+
return min(min_cost[(n - 1) % 2])
2325

2426
# Time: O(n)
2527
# Space: O(n)
26-
class Solution2:
27-
# @param {integer[][]} costs
28-
# @return {integer}
28+
class Solution2(object):
2929
def minCost(self, costs):
30+
"""
31+
:type costs: List[List[int]]
32+
:rtype: int
33+
"""
3034
if not costs:
3135
return 0
3236

@@ -36,4 +40,4 @@ def minCost(self, costs):
3640
costs[i][1] += min(costs[i - 1][0], costs[i - 1][2])
3741
costs[i][2] += min(costs[i - 1][0], costs[i - 1][1])
3842

39-
return min(costs[n - 1][0], costs[n - 1][1], costs[n - 1][2])
43+
return min(costs[n - 1])

0 commit comments

Comments
 (0)