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)
相关推荐
ATMQuant1 小时前
量化指标解码21:逻辑回归支撑阻力 - 让逻辑回归给关键价位打分
python·机器学习·逻辑回归·量化交易·技术指标
q0371801 小时前
深色 IDE 截图 OCR 老是漏字,我加了一层预处理,顺手把识别结果做成了可搜索历史
python
蜗牛8752 小时前
个人机票监控开源项目:6 个平台、10 条通道的自托管方案
python
秋名山小白2 小时前
Playwright UI 自动化测试实战教程
python·ui
AI源码3 小时前
基于 Python 的汽车市场数据分析与可视化平台
python·数据分析·汽车
会飞锦鲤3 小时前
基于 SVM + HOG 的铸造缺陷检测系统
python·opencv·机器学习·计算机视觉·缺陷检测·图像分类·svm
starrysky8104 小时前
zipfile 中文乱码修复:把已知 GBK 旧 ZIP 解压到正确中文目录
python
用户91294046848425 小时前
Codex 从零到能交付(09):让 Codex 写有用的测试,而不是只测成功路径
python
文丑颜不良啊5 小时前
LeetCode2081~2100题目解析
java·leetcode
2601_967987375 小时前
Debian如何配置Python调试工具
python·debian·pdb·调试工具·ipdb