[LeetCode&Python] Problem 917. Reverse Only Letters
2021-05-16 03:30
标签:rev div ons input eve let list HERE sel Given a string Example 1: Example 2: Example 3: Note: [LeetCode&Python] Problem 917. Reverse Only Letters 标签:rev div ons input eve let list HERE sel 原文地址:https://www.cnblogs.com/chiyeung/p/9750027.htmlS
, return the "reversed" string where all characters that are not a letter stay in the same place, and all letters reverse their positions.Input: "ab-cd"
Output: "dc-ba"
Input: "a-bC-dEf-ghIj"
Output: "j-Ih-gfE-dCba"
Input: "Test1ng-Leet=code-Q!"
Output: "Qedo1ct-eeLg=ntse-T!"
S.length
33
S
doesn‘t contain \
or "
class Solution:
def reverseOnlyLetters(self, S):
"""
:type S: str
:rtype: str
"""
n=len(S)
s=list(S)
i=0
j=n-1
while i
上一篇:Go语言的JSON输入(解码)(反序列化)之struct存储
下一篇:六种排序
文章标题:[LeetCode&Python] Problem 917. Reverse Only Letters
文章链接:http://soscw.com/index.php/essay/86083.html