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)
相关推荐
Elaine33613 小时前
【 基于 TensorFlow+CNN 的水果图像识别系统设计与实现】
人工智能·python·深度学习·计算机视觉·cnn·tensorflow
2401_8414956413 小时前
【机器学习】深度神经网络(DNN)
人工智能·python·深度学习·神经网络·机器学习·dnn·深度神经网络
njsgcs13 小时前
ai流水线式调用命令
人工智能·python
老歌老听老掉牙14 小时前
Python JSON 配置文件读写简明指南
python·json
Salt_072814 小时前
DAY 54 对抗生成网络
网络·python·神经网络·机器学习·计算机视觉
百锦再14 小时前
Elements Plus 跨设备自适应显示问题综合解决方案
python·flutter·小程序·uni-app·k8s·tornado·net
老歌老听老掉牙14 小时前
从战场到商场:最优化算法如何用数学重塑世界?
python·算法·最优化
im_AMBER14 小时前
Leetcode 94 合并零之间的节点
数据结构·c++·笔记·学习·算法·leetcode
weixin_4407305014 小时前
java面向对象OPP-三大特性
java·开发语言·python
七夜zippoe14 小时前
Python多进程编程实战:彻底突破GIL限制的完整指南
python·编程·多进程·process·gil