技术栈

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
相关推荐
Wyawsl
几秒前
Python操作MySQL数据库
数据库·python·mysql
_深海凉_
8 分钟前
LeetCode热题100- 字母异位词分组
leetcode
SuperEugene
8 分钟前
Python 异步 async/await:为什么 AI 框架大量使用?| 基础篇
开发语言·人工智能·python
洛水水
10 分钟前
【力扣100题】14.两数相加
c++·算法·leetcode
float_com
13 分钟前
LeetCode80. 删除有序数组中的重复项 II
leetcode
SMF1919
14 分钟前
【uv】Python包管理器uv安装和应用
开发语言·python·uv
pwn蒸鱼
14 分钟前
leetcode:21. 合并两个有序链表
算法·leetcode·链表
gergul
14 分钟前
在llama-cpp-python中使用自己编译的llama.cpp,解决pip install llama-cpp-python报错
python·llama·llama.cpp·llamacpppython
深蓝轨迹
15 分钟前
#Python零基础机器学习入门教程
人工智能·python·机器学习
洛水水
16 分钟前
【力扣100题】15.删除链表的倒数第 N 个结点
算法·leetcode·链表
热门推荐
01GitHub 镜像站点02一周AI热点速览(2026.03.31-04.06):GPT-6曝光、谷歌开源Gemma 4、资本狂飙与模型军备竞赛03OpenClaw 请求超时 llm request timed out 怎么解决?3 种方案实测,附完整排查流程04AI 编程效率翻倍:Superpowers Skills 上手清单 + 完整指南05实测!Gemma 4 成功跑在安卓手机上:离线 AI 助手终于来了06VMware Workstation Pro 17 虚拟机完整安装教程(2026最新)07MySQL表约束详解:8大核心约束实战指南08Oh My Codex 快速使用指南09CodeBuddy与WorkBuddy深度对比:腾讯两款AI工具差异及实操指南10UV安装并设置国内源