Skip to content

Commit f3725bd

Browse files
authored
Adjust spacing
1 parent 11822e5 commit f3725bd

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

python/0135-candy.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
class Solution:
22
def candy(self, ratings: List[int]) -> int:
33
n = len(ratings)
4-
#Initialize with one candy becuase each child must have at least one candy.
4+
# Initialize with one candy becuase each child must have at least one candy.
55
candies = [1] * n
66

7-
#Iterate from left to right
7+
# Iterate from left to right
88
for i in range(1, n):
9-
#Check if current rating is greater than left neighbor
10-
if ratings[i] > ratings[i-1]:
11-
#Rating is higher so deserves more candy than left neighbor
12-
candies[i] = candies[i-1] + 1
9+
# Check if current rating is greater than left neighbor
10+
if ratings[i] > ratings[i - 1]:
11+
# Rating is higher so deserves more candy than left neighbor
12+
candies[i] = candies[i - 1] + 1
1313

14-
#Iterate from right to left
15-
for i in range(n-2, -1, -1):
16-
#Check if current rating is greater than right neighbor
17-
if ratings[i] > ratings[i+1]:
18-
#Take max to check if the value is already greater than its right neighbor + 1.
19-
candies[i] = max(candies[i], candies[i+1] + 1)
14+
# Iterate from right to left
15+
for i in range(n - 2, -1, -1):
16+
# Check if current rating is greater than right neighbor
17+
if ratings[i] > ratings[i + 1]:
18+
# Take max to check if the value is already greater than its right neighbor + 1.
19+
candies[i] = max(candies[i], candies[i + 1] + 1)
2020

21-
return sum(candies)
21+
return sum(candies)

0 commit comments

Comments
 (0)