Trains the technique from
LeetCode 824Goat LatinThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
Children at a playground trade messages in a word game called Rook Talk. A sentence is rewritten one word at a time, and the rewritten words stay in their original order, separated by single spaces.
Take the word sitting in position i, counting the first word as position 1, and apply these steps in order:
aeiou in either case, leave its letters where they are; otherwise take that first letter off the front and put it on the end;ok to the word;k a further i times.Letter case is never altered: a letter that arrives uppercase stays uppercase wherever it ends up.
Return the rewritten sentence.
Example 1
`wren` does not start with a vowel, so it becomes `renw`, then `ok`, then one k: `renwokk`. `and` starts with a vowel and keeps its letters, then `ok` and two k's: `andokkk`. `heron` becomes `eronh`, then `ok` and three k's: `eronhokkkk`.
Example 2
`Zebra` does not start with a vowel, so the capital `Z` moves to the end and stays capital, giving `ebraZ`, then `ok` and one k. `crossing` becomes `rossingc`, then `ok` and two k's.
Example 3
`Otter` begins with an uppercase vowel, so its letters stay put, and `ok` plus one k is appended.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def to_rook_talk(sentence: str) -> str:public String toRookTalk(String sentence)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.