update
This commit is contained in:
11
leetcode_py/2000.py
Normal file
11
leetcode_py/2000.py
Normal 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
|
||||
Reference in New Issue
Block a user