Mark Vowels on a Shipment Label
Context
A warehouse prints handling labels for outgoing shipments. To make selected labels easier to inspect, the printer may change up to a given number of lowercase vowels into the marker letter x. Spaces and consonants must remain unchanged, and vowels are considered from left to right.
Problem
Given a shipment label and a replacement quota, process the label from left to right. For each lowercase vowel (a, e, i, o, or u), replace it with the lowercase letter x while the quota still allows replacements. Once the quota is used, leave every later character unchanged. Return the resulting label.
Spaces and consonants are never replaced. The returned label must have the same length and preserve the order of every character. If the quota is zero, return the label unchanged; if the label is empty, return an empty string.
Examples
label = "alpha team"quota = 2"xlphx team"label = "blue rocket"quota = 8"blxx rxckxt"label = "quiet zone"quota = 0"quiet zone"Constraints
0 <= len(label) <= 1000000 <= quota <= len(label)label contains lowercase letters and spaces- Types:
labelis str,quotais int; result is str
Function signature
def mark_shipment_label(label: str, quota: int) -> str
labelstr- The shipment label, containing lowercase letters and spaces.
quotaint- The maximum number of vowels that may be replaced.
- returns str
- The label after replacing up to quota vowels from left to right with x.
Adapted from MBPP problem task_220 (CC BY 4.0). Rewritten, extended and verified by Iksha.
Notes
- Only lowercase vowels are eligible for replacement.
- The replacement limit is never exceeded.