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)
相关推荐
FriendshipT8 分钟前
评估指标:AP(Average Precision)、mAP(Mean Average Precision)
人工智能·python·计算机视觉·map·ap
见青..12 分钟前
攻防世界-web:php2、easyupload
笔记·安全·题解
Frostnova丶16 分钟前
LeetCode 1415. 长度为 n 的开心字符串中字典序第 k 小的字符串
数据结构·算法·leetcode
美好的事情能不能发生在我身上16 分钟前
Leetcode热题100中的:技巧专题
算法·leetcode·职场和发展
为你奋斗!26 分钟前
Playwright 录屏功能启用离线安装依赖pywin32 pillow
开发语言·chrome·python·语言模型·迁移学习
zh路西法26 分钟前
【宇树机器人强化学习】(二):ActorCritic网络和ActorCriticRecurrent网络的python实现与解析
开发语言·python·深度学习·机器学习·机器人
`Jay31 分钟前
高并发数据采集:隧道代理池架构设计与实现
爬虫·python·学习·golang·代理模式
Csvn31 分钟前
Python 装饰器从入门到实战
python
AsDuang39 分钟前
Python 3.12 MagicMethods - 50 - __lshift__
开发语言·python
x_xbx42 分钟前
LeetCode:53. 最大子数组和
算法·leetcode·职场和发展