Submission Detail

480 / 480 test cases passed.
Status:

Accepted

Runtime: 11 ms
Memory Usage: 44.6 MB
Submitted: 0 minutes ago
loading
Runtime Error Message:
Last executed input:
Input:
Output:
Expected:

Accepted Solutions Runtime Distribution

0
50
100
150
200
250
300
350
400
450
500
550
600
650
5
10
15
20
java
You are here!
Your runtime beats 33.97 % of java submissions.
Runtime (ms)
Distribution (%)

0
50
100
150
200
250
300
350
400
450
500
550
600
650
5
10
15
20
Zoom area by dragging across this chart

Accepted Solutions Memory Distribution

42000
42500
43000
43500
44000
44500
45000
45500
46000
2.5
5.0
7.5
10.0
12.5
15.0
java
You are here!
Your memory usage beats 27.49 % of java submissions.
Memory (KB)
Distribution (%)

42000
42500
43000
43500
44000
44500
45000
45500
46000
5
10
15
Zoom area by dragging across this chart

Invite friends to challenge Reverse Vowels of a String


Submitted Code: 0 minutes ago

Language: java

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
44
45
46
47
48
49
50
51
52
53
54
class Solution {
public String reverseVowels(String s) {
int count = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == 'a' || s.charAt(i) == 'A' ||
s.charAt(i) == 'e' || s.charAt(i) == 'E' ||
s.charAt(i) == 'i' || s.charAt(i) == 'I' ||
s.charAt(i) == 'o' || s.charAt(i) == 'O' ||
s.charAt(i) == 'u' || s.charAt(i) == 'U') {
count++;
}
}
char[] vowels = new char[count];
int[] indices = new int[count];
int it = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == 'a' || s.charAt(i) == 'A' ||
s.charAt(i) == 'e' || s.charAt(i) == 'E' ||
s.charAt(i) == 'i' || s.charAt(i) == 'I' ||
s.charAt(i) == 'o' || s.charAt(i) == 'O' ||
s.charAt(i) == 'u' || s.charAt(i) == 'U') {
vowels[it] = s.charAt(i);
indices[it] = i;
it++;
}
}
// reverse vowels
int left = 0;
int right = vowels.length - 1;
while (left < right) {
char temp = vowels[left];
vowels[left] = vowels[right];
vowels[right] = temp;
left++;
right--;
}
char st[] = s.toCharArray();
for (int i = 0; i < indices.length; i++)
st[indices[i]] = vowels[i];
s = new String(st);
return s;
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX