Problem · Array

Reverse the Interior of Vowel-Bounded Words

Learn this problem
EasyTiktok logoTiktokINTERNOA
See Tiktok hiring insights

Problem statement

You are given an array of strings text, where each string represents a word.

A word qualifies when both its first and last characters are vowels. The vowels are a, e, i, o, and u, and the check is case-insensitive.

For every qualifying word, reverse only the substring between its first and last characters. Keep the two endpoint characters unchanged. Leave every other word unchanged and preserve the original array order.

Return the modified array of strings.

Function

solution(text: String[]) → String[]

Examples

Example 1

text = ["apple","banana","OranGe"]return = ["alppe","banana","OGnare"]
  • apple begins with a and ends with e, so reversing ppl produces alppe.
  • banana does not begin with a vowel and remains unchanged.
  • OranGe begins and ends with vowels; reversing ranG produces OGnare.

Constraints

  • Every element of text is a non-empty word.
  • Vowel checks are case-insensitive, while every character's original case is preserved.

More Tiktok problems

drafts saved locally
public String[] solution(String[] text) {
    // Write your code here.
}
text["apple","banana","OranGe"]
expected["alppe", "banana", "OGnare"]
checking account