Trains the technique from
LeetCode 97Interleaving StringThis 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.
Two feed lanes discharge onto a single packing belt. Each lane holds a queue of parts written as a string of lowercase letters, one letter per part: left is the left lane and right the right lane, and the first letter of each is the part at the head of that lane.
An operator clears both lanes onto the belt one part at a time. At every step they pick a lane that still has parts and release the part at its head. Nothing is skipped, nothing is added, and neither lane may be reordered, so the parts of a single lane arrive on the belt in the order they were queued.
belt is the run that came off the belt, head part first. Return true when some sequence of lane picks produces exactly belt, and false otherwise.
Example 1
Releasing a from the left lane, then c from the right, then b from the left, then d from the right lays down a, c, b, d. Within each lane the parts came off in their queued order.
Example 2
The belt carries all four parts, but d comes off before c while the right lane queues c ahead of d, so no run of picks can produce it.
Example 3
The left lane is empty, so every pick comes from the right lane and the belt shows that lane's own 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 is_merge(left: str, right: str, belt: str) -> bool:public boolean isMerge(String left, String right, String belt)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.