Python | Leetcode Python题解之第514题*之路-题解:

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)
上一篇:python 实现一个简单的浏览器引擎


下一篇:学习新技能的五大步骤