Python, 96.13%


  • 0
    X

    '''

        vow={'a','e','i','o','u','A','E','I','O','U'}
    
        pos=[]
        val=[]
        li = list(s)
        
        for i in range(len(li)):
            if li[i] in vow:
                pos.append(i)
                val.append(li[i])
        i = 0
        
        for x in val[::-1]:
            li[pos[i]] = x
            i += 1
            
        return ''.join(li)
    

    '''

    set will reduce the time.


Log in to reply
 

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