https://leetcode.com/problems/reverse-prefix-of-word/description
1 2 3 4 5 6 7 | class Solution: def reversePrefix(self, word: str, ch: str) -> str: if word.find(ch) == -1: return word else: return word[:word.find(ch)+1][::-1] + word[word.find(ch)+1:] | cs |
반응형
'python-algorithm' 카테고리의 다른 글
백준 32025 체육은 수학과목 입니다 (0) | 2024.07.15 |
---|---|
백준 30979 유치원생 파댕이 돌보기 (0) | 2024.06.19 |
leetcode 3131. Find the Integer Added to Array I (0) | 2024.04.30 |
leetcode 1266. Minimum Time Visiting All Points (1) | 2024.04.27 |
leetcode 2855. Minimum Right Shifts to Sort the Array (0) | 2024.04.26 |
댓글