Skip to content

Commit e322667

Browse files
committed
update candy.py
make it a bit more pythonic.
1 parent fe30032 commit e322667

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

Python/candy.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# Time: O(n)
22
# Space: O(n)
33

4-
import operator
5-
from functools import reduce
6-
74
class Solution(object):
85
# @param ratings, a list of integer
96
# @return an integer
@@ -17,5 +14,4 @@ def candy(self, ratings):
1714
if ratings[i - 1] > ratings[i] and candies[i - 1] <= candies[i]:
1815
candies[i - 1] = candies[i] + 1
1916

20-
return reduce(operator.add, candies)
21-
17+
return sum(candies)

0 commit comments

Comments
 (0)