Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions codeflash/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Solution:
_vowels = set("aeiouAEIOU") # noqa: RUF012

def reverseVowels(self, s: str) -> str:
left, right = 0, len(s) - 1
chars = list(s)
vowels = self._vowels # Local variable for faster lookup

while left < right:
# Advance left pointer to next vowel
while left < right and chars[left] not in vowels:
left += 1
# Advance right pointer to previous vowel
while left < right and chars[right] not in vowels:
right -= 1
if left < right:
chars[left], chars[right] = chars[right], chars[left]
left += 1
right -= 1

return "".join(chars)
Loading