This commit is contained in:
2024-12-11 17:31:43 +08:00
parent fdaa94a0fa
commit 5e6299439c
6 changed files with 182 additions and 19 deletions

11
leetcode_py/2000.py Normal file
View File

@@ -0,0 +1,11 @@
import re
class Solution:
def reversePrefix(self, word: str, ch: str) -> str:
match = re.search(rf"{ch}", word)
if match:
position = match.start()
return word[: position + 1][::-1] + word[position + 1 :]
else:
return word