File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -161,7 +161,18 @@ class Solution {
161161```
162162
163163Python:
164-
164+ ``` python
165+ class Solution :
166+ def candy (self , ratings : List[int ]) -> int :
167+ candyVec = [1 ] * len (ratings)
168+ for i in range (1 , len (ratings)):
169+ if ratings[i] > ratings[i - 1 ]:
170+ candyVec[i] = candyVec[i - 1 ] + 1
171+ for j in range (len (ratings) - 2 , - 1 , - 1 ):
172+ if ratings[j] > ratings[j + 1 ]:
173+ candyVec[j] = max (candyVec[j], candyVec[j + 1 ] + 1 )
174+ return sum (candyVec)
175+ ```
165176
166177Go:
167178
172183* 作者微信:[ 程序员Carl] ( https://mp.weixin.qq.com/s/b66DFkOp8OOxdZC_xLZxfw )
173184* B站视频:[ 代码随想录] ( https://space.bilibili.com/525438321 )
174185* 知识星球:[ 代码随想录] ( https://mp.weixin.qq.com/s/QVF6upVMSbgvZy8lHZS3CQ )
175- <div align="center"><img src=../pics/公众号.png width=450 alt=> </img ></div >
186+ <div align="center"><img src=../pics/公众号.png width=450 alt=> </img ></div >
You can’t perform that action at this time.
0 commit comments