My python Solution best solution


  • 0
    S
        s=list(s)
        i=0
        j=len(s)-1
        seen=set(['a','e','i','o','u','A','E','I','O','U'])
        
        while i<j:
            if s[i] in seen and s[j] in seen:
                   temp=s[i]
                   s[i]=s[j]
                   s[j]=temp
                   i+=1
                   j-=1
            else:
                
                if s[i] in seen:
                    j-=1
                elif s[j] in seen:
                    i+=1
                else:
                    i+=1
                    j-=1
        return ''.join(s)

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.