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

题目:

题解:

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)
相关推荐
weixin_4211334118 分钟前
应用日志监控
python
CHANG_THE_WORLD1 小时前
Python 学习三 Python字符串拼接详解
开发语言·python·学习
测试老哥2 小时前
Postman接口测试基本操作
自动化测试·软件测试·python·测试工具·测试用例·接口测试·postman
winfredzhang2 小时前
基于wxPython的TodoList任务管理器开发详解
python·wxpython·todolist·持久
釉色清风2 小时前
在openEuler玩转Python
linux·开发语言·python
Blossom.1182 小时前
基于多智能体强化学习的云资源调度系统:如何用MARL把ECS成本打下来60%
人工智能·python·学习·决策树·机器学习·stable diffusion·音视频
qq_2704900962 小时前
车牌识别技术:从深度学习到产业应用的全面解析
python·cnn
Data_agent3 小时前
1688按图搜索1688商品(拍立淘)API ,Python请求示例
爬虫·python·算法·图搜索算法
吃好喝好玩好睡好3 小时前
OpenHarmony混合开发实战指南
c语言·python·flutter·vr·visual studio
white-persist3 小时前
【攻防世界】reverse | re1-100 详细题解 WP
c语言·开发语言·网络·汇编·python·算法·网络安全