HTMLify
LeetCode | Reverse Vowels of a String | Python
Views: 383 | Author: abh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | class Solution: def reverseVowels(self, s: str) -> str: rvs = "" for c in s[::-1]: if c in "aeiouAEIOU": rvs += c ns = "" p = 0 for c in s: if c in "aeiouAEIOU": ns += rvs[p] p += 1 else: ns += c return ns |