Write a function that takes a string as input and reverse only the vowels of a string.
Example 1:
Given s = "hello", return "holle".
Example 2:
Given s = "leetcode", return "leotcede".
class Solution(object):
def reverseVowels(self, s):
v = ['a','e','i','o','u','A','E','I','O','U']
vovs = []
s = list(s)
for i in xrange(len(s)):
if s[i] in v:
vovs += s[i],
s[i] = None
#vovs.reverse()
#print vovs,s
for i in xrange(len(s)):
if s[i] == None:
s[i] = vovs.pop()
#print s
return ''.join(s)
899



被折叠的 条评论
为什么被折叠?



