自我监督刷题记录处9
第9天,,,,感冒了
Leetcode 1103(打卡). Distribute Candies to People
(Easy Level)
class Solution:
def distributeCandies(self, candies: int, num_people: int) -> List[int]:
num = [0]*num_people
give = 1
while candies >= give:
num[(give-1)%num_people]+give
give -= 1
num += 1
num[(give-1)%num_people] + candies
return num
Leetcode 38 Count and Say
(Easy Level)
class Solution:
def countAndSay(self, n: int) -> str:
if n ==1:
return '1'
if n == 2:
return '11'
pre = '11'
for i in range(3,n+1):
count = 1
res = ''count +=1
for j in range(1,len(pre)):
if pre[j-1] == pre[j]:
count +=1
else:
res += str(count)+pre[j-1]
count = 1
res += str(count) + pre[j]
pre = res
return pre
先这样吧。。。。36.9应该是在生病的边缘游走把