Easy
You are given a string s that consists of lowercase English letters.
Return the string obtained by removing all trailing vowels from s.
The vowels consist of the characters 'a', 'e', 'i', 'o', and 'u'.
Example 1:
Input: s = “idea”
Output: “id”
Explanation:
Removing "id**ea**", we obtain the string "id".
Example 2:
Input: s = “day”
Output: “day”
Explanation:
There are no trailing vowels in the string "day".
Example 3:
Input: s = “aeiou”
Output: “”
Explanation:
Removing "**aeiou**", we obtain the string "".
Constraints:
1 <= s.length <= 100s consists of only lowercase English letters.public class Solution {
public String trimTrailingVowels(String s) {
int i = s.length() - 1;
while (i >= 0
&& (s.charAt(i) == 'a'
|| s.charAt(i) == 'e'
|| s.charAt(i) == 'i'
|| s.charAt(i) == 'o'
|| s.charAt(i) == 'u')) {
i--;
}
return s.substring(0, i + 1);
}
}