Given a string(word) with a combination of vowels and consonants , we want to reverse just the vowels only with out disturbing the place of the consonants
Example
happen Ans: heppan
public string ReverseVowels(string s) {
StringBuilder sb = new StringBuilder(s);
char [] v = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'};
int i=0, j=s.Length-1;
while(i<j)
{
if(v.Contains(sb[i]))
{
if(v.Contains(sb[j]))
{
char temp = sb[i];
sb[i] = sb[j];
sb[j] = temp;
i++;j--;
}
else
j--;
}
else
i++;
}
return sb.ToString();
}