古之立大事者,不惟有超世之才,亦必有坚忍不拔之志。这篇文章主要讲述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报数】
推荐阅读
- pythonnohup python 提示 ImportError: No module named requests
- #夏日挑战赛# FFH从零开始的鸿蒙机器学习之旅-NLP情感分析
- linux搭建redis
- 快速了解常用的对称加密算法,再也不用担心面试官的刨根问底
- 机器学习总结笔记
- #云原生征文#深入了解Kubernetes(k8s)Service
- python打印print打印语句当中的f是什么
- Containerd容器运行时(yum安装与二进制安装,哪个更适合你())
- selenium强制等待,隐式等待,显式等待