8ms C solution


  • 0
    D

    char* reverseVowels(char* s)
    {
    int i,j;
    char temp;
    j=strlen(s)-1;
    i=0;

    for(;i!=j && i<j;)
    {
    if(s[i]=='a' || s[i]=='e' || s[i] == 'i' ||s[i] == 'o' || s[i] == 'u'|| s[i]=='A' || s[i] == 'E' || s[i] == 'I' || s[i] == 'O'|| s[i] == 'U')
        {
            for(;j!=i && j>i;)
            {
                if(s[j]=='a' || s[j]=='e' || s[j]=='i' || s[j] == 'o' || s[j]=='u'
                     || s[j]=='A' || s[j]=='E' || s[j]=='I' || s[j] == 'O' || s[j]=='U')
                {
                    temp = s[j];
                    s[j]=s[i];
                    s[i]=temp;
                    j--;
                    break;
                }
                j--;
            }
        }
        i++;
    }
    return s;
    

    }


  • 0
    D
    This post is deleted!

  • 0
    D

    @deepvkk okk got it


  • 0
    D

    hey ur code is not running


Log in to reply
 

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