public class Solution { public string ReverseVowels(string s) { var str = s.ToList(); var Vowels = new List(); for (int i = 0; i < str.Count; i++) { var c = str[i]; if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U') { Vowels.Add(c); } } if (Vowels.Count > 0) { Vowels.Reverse(); int j = 0; for (int i = 0; i < str.Count; i++) { var c = str[i]; if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U') { str[i] = Vowels[j]; j++; } } } StringBuilder sb = new StringBuilder(); foreach (var c in str) { sb.Append(c); } return sb.ToString(); }}