Trains the technique from
LeetCode 140Word Break IIThis 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.
An archive holds reel tapes whose printed labels ran the track names together with every separator worn away. You are given the label tape and titles, the catalogue of track names the archive recognises.
Restore the label. A restoration is an ordered run of catalogue titles whose letters, written one after another with nothing between them, give tape exactly. A title may be reused as often as it helps, and the catalogue may hold titles that no restoration uses.
Return every restoration as a string, with one blank space between neighbouring titles. The restorations may come back in any order. Return an empty list when the label cannot be restored from the catalogue at all.
Example 1
Three runs of titles spell the label: dub then dub, du then bdub, and du then b then du then b.
Example 2
The label splits after harp and after harps, so two restorations exist and both are reported.
Example 3
No catalogue title covers the trailing x, so nothing can be restored and the list is empty.
The values you return may be in any order.
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 tape_track_splits(tape: str, titles: list[str]) -> list[str]:public List<String> tapeTrackSplits(String tape, List<String> titles)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.