-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRevVowel.java
More file actions
35 lines (29 loc) · 945 Bytes
/
RevVowel.java
File metadata and controls
35 lines (29 loc) · 945 Bytes
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
import java.util.Stack;
import java.util.Queue;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
public class RevVowel {
public static void main(String[] args) {
Queue<Character> a = new LinkedList<>();
String s = "Hello";
char[] cha = s.toCharArray();
for(int i = s.length()-1; i >= 0; i--) {
char ch = cha[i];
if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
a.add(ch);
}
}
StringBuilder sb = new StringBuilder();
for(int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
System.out.println(a);
sb.append(a.remove());
}else{
sb.append(ch);
}
}
System.out.println(sb);
}
}