技术栈

Python | Leetcode Python题解之第514题自由之路

Mopes__2024-10-28 19:38

题目:

题解:

python 复制代码
Test = "godding"
target = "d"

i = 0

left = i
lc = 0
right = i
rc = 0

while Test[left] != target:
    left -= 1
    lc += 1
    if left == -1:
        left = len(Test) - 1

while Test[right] != target:
    right += 1
    rc += 1
    if right == len(Test):
        right = 0


print(left, lc)
print(right, rc)
上一篇:考研要求掌握的C语言程度(堆排序)1
下一篇:【代码随想录Day53】图论Part05
相关推荐
明月_清风
1 小时前
Python 性能微观世界:列表推导式 vs for 循环
后端·python
明月_清风
1 小时前
Python 性能翻身仗:从 O(n) 到 O(1) 的工程实践
后端·python
helloweilei
17 小时前
python 抽象基类
python
用户835629078051
17 小时前
Python 实现 PPT 转 HTML
后端·python
zone7739
1 天前
004:RAG 入门-LangChain读取PDF
后端·python·面试
zone7739
1 天前
005:RAG 入门-LangChain读取表格数据
后端·python·agent
树獭非懒
2 天前
AI大模型小白手册|Embedding 与向量数据库
后端·python·llm
唐叔在学习
2 天前
就算没有服务器,我照样能够同步数据
后端·python·程序员
曲幽
2 天前
FastAPI流式输出实战与避坑指南:让AI像人一样“边想边说”
python·ai·fastapi·web·stream·chat·async·generator·ollama
Flittly
2 天前
【从零手写 AI Agent:learn-claude-code 项目实战笔记】(1)The Agent Loop (智能体循环)
python·agent
热门推荐
01GitHub 镜像站点02OpenClaw 使用和管理 MCP 完全指南03OpenClaw + 飞书(Feishu)环境搭建指南04本地部署 OpenClaw + DeepSeek-R1 完全指南05Window 10部署openclaw报错node.exe : npm error code 12806OpenClaw优化飞书API 额度已耗尽问题07Claude Code + GLM4.7 避坑指南:解决 Unable to connect to Anthropic services08OpenClaw 连接飞书完整指南:插件安装、配置与踩坑记录09小黑课堂计算机二级WPSoffice题库软件下载安装教程(2026年3月最新版)10OpenClaw 飞书机器人不回复消息?3 小时踩坑总结