All problems
0149EasyTwo PointersString

Marquee Vowel Sockets

Tracked in this browser only
Write code

Trains the technique from

LeetCode 345Reverse Vowels of a String

This 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.

A theatre spells the evening listing on its marquee out of character tiles clamped along one rail. A tile sits in a loose socket when its character is a, e, i, o or u, written either as a capital or in lower case. Every other tile on the rail is riveted down and cannot be moved, whatever character it shows.

The stagehand lifts all of the loose tiles off the rail, holds them, and drops them back into exactly the same sockets, but working from the far end of the rail towards the near end. The upshot is that the loose tiles occupy the same positions as before with their order along the rail turned around, while every riveted tile is untouched. Tiles are never re-cut, so a capital tile stays a capital wherever it lands.

You are given the current marquee text as the string board, made of printable ASCII characters. Return the text the marquee shows once the stagehand steps back.

Examples

Example 1

Input
board = "TOP hat"
Output
"TaP hOt"

Two tiles are loose, the capital in position 1 and the lower-case one in position 5. They trade sockets, and each keeps the case it was cut with.

Example 2

Input
board = "Grand Opening"
Output
"Grind epOnang"

The four loose tiles sit in positions 2, 6, 8 and 10; reading them back to front gives the tiles that land in those same four positions. The space and every riveted tile stay put.

Example 3

Input
board = "myrtle"
Output
"myrtle"

Only one tile here is loose, so lifting it and dropping it back changes nothing. A tile showing the letter y is riveted like any other consonant tile.

Constraints

  • 1 <= board.length <= 3 * 10^5
  • board consists of printable ASCII characters.
  • A tile is loose only for the ten characters a, e, i, o, u, A, E, I, O, U.

The signature

The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.

Python
def marquee_vowel_sockets(board: str) -> str:
Java
public String marqueeVowelSockets(String board)
September 7
Apply