← 返回 instacart 的题目列表Flip Inner Segment If String Starts and Ends With Vowels
类型:online_judge
Given an array of strings arr, transform each string s as follows and return the resulting array:
If both the first and last characters of s are vowels, reverse (mirror) the inner substring of s (i.e., s[1:-1]) and then concatenate it back with the original first and last characters.
Otherwise, keep s unchanged.
Vowels are a, e, i, o, u in both lowercase and uppercase.
Input
Line 1: integer n (array length)
Next n lines: one string per line
Output
Print n lines, each the transformed string.
Constraints
1 <= n <= 2*10^5
Total length of all strings <= 2*10^5
Example
Input:
4
apple
abca
a
xyz
Output:
alppe
acba
a
xyz
Example
Input
4
abca
xyz
a
AeIoU
Output
acba
xyz
a
AUoIe