技术栈

Python | Leetcode Python题解之第38题外观数列

Mopes__2024-04-20 18:31

题目:

题解:

python 复制代码
class Solution:
    def countAndSay(self, n: int) -> str:
        prev = "1"
        for i in range(n-1):
            curr = ""
            pos = 0
            start = 0

            while pos < len(prev):
                while pos < len(prev) and prev[pos] == prev[start]:
                    pos += 1
                curr += str(pos - start) + prev[start]
                start = pos
            prev = curr
        
        return prev
上一篇:Webrtc 信令服务器实现
下一篇:2024.4.16 Python爬虫复习day04
相关推荐
两万五千个小时
1 小时前
落地实现 Anthropic Multi-Agent Research System
人工智能·python·架构
哈里谢顿
3 小时前
Python 高并发服务限流终极方案:从原理到生产落地(2026 实战指南)
python
用户835629078051
18 小时前
无需 Office:Python 批量转换 PPT 为图片
后端·python
markfeng8
20 小时前
Python+Django+H5+MySQL项目搭建
python·django
GinoWi
20 小时前
Chapter 2 - Python中的变量和简单的数据类型
python
JordanHaidee
20 小时前
Python 中 `if x:` 到底在判断什么?
后端·python
ServBay
21 小时前
10分钟彻底终结冗长代码,Python f-string 让你重获编程自由
后端·python
闲云一鹤
21 小时前
Python 入门(二)- 使用 FastAPI 快速生成后端 API 接口
python·fastapi
Rockbean
1 天前
用40行代码搭建自己的无服务器OCR
服务器·python·deepseek
曲幽
1 天前
FastAPI + Ollama 实战:搭一个能查天气的AI助手
python·ai·lora·torch·fastapi·web·model·ollama·weatherapi
热门推荐
01GitHub 镜像站点02【OpenClaw 本地实战 Ep.3】突破瓶颈:强制修改 openclaw.json 解锁 32k 上下文记忆03OpenClaw 使用和管理 MCP 完全指南04Claude Code + GLM4.7 避坑指南:解决 Unable to connect to Anthropic services05AI Agent 平台横评:ZeroClaw vs OpenClaw vs Nanobot06AI 规范驱动开发“三剑客”深度对比:Spec-Kit、Kiro 与 OpenSpec 实战指南07Clawdbot部署教程:解决‘gateway token missing’授权问题的完整步骤08Window 10部署openclaw报错node.exe : npm error code 12809让 Trae IDE 智能体 “读懂”文档 Excel+PDF+DOCX :mcp-documents-reader 工具使用指南10本地部署 OpenClaw + DeepSeek-R1 完全指南