Leetcode 38报数

古之立大事者,不惟有超世之才,亦必有坚忍不拔之志。这篇文章主要讲述Leetcode 38报数相关的知识,希望能为你提供帮助。
题目描述补充说明一下题目的意思

解法一:

class Solution:
def countAndSay(self, n: int) -> str:
prev_person = 1
for i in range(1,n):
next_person, num, count = , prev_person[0], 1
for j in range(1,len(prev_person)):
if prev_person[j] == num:count += 1
else:
next_person += str(count) + num
num = prev_person[j]
count = 1
next_person += str(count) + num
prev_person = next_person
return prev_person

参考链接
??? https://leetcode-cn.com/problems/count-and-say/solution/ji-su-jie-bu-di-gui-zhi-ji-lu-qian-hou-liang-ren-p/??
【Leetcode 38报数】


    推荐阅读