-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreverseVowels_lc.cs
43 lines (35 loc) · 1.09 KB
/
reverseVowels_lc.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
public class Solution {
public string ReverseVowels(string s) {
string vow = "";
string temp = "";
foreach(char c in s)
{
if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||
c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U')
{
vow += c;
}
}
if (vow != null)
{
var ff= vow.Reverse();
vow = "";
foreach(var e in ff)
{
vow += e;
}
}
for(int i=0;i<s.Length;i++)
{
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')
{
temp += vow[0];
vow=vow.Substring(1);
}
else
temp += s[i];
}
return temp;
}
}