IT/코딩테스트
[Leetcode] 2000. Reverse Prefix of Word
이주디
2024. 5. 2. 00:21
728x90
https://leetcode.com/problems/reverse-prefix-of-word
class Solution:
def reversePrefix(self, word: str, ch: str) -> str:
index = word.find(ch)
if index == -1:
return word
return word[index::-1] + word[index+1:]
728x90