Trains the technique from
LeetCode 6Zigzag ConversionThis 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 plate engraver cuts the characters of message into rows parallel horizontal tracks, numbered 0 at the top through rows - 1 at the bottom. It stamps the characters one at a time in the order they appear.
The head starts on track 0 and drops one track after each stamp until it stamps into the bottom track; it then climbs one track after each stamp until it stamps into the top track, and it keeps swinging that way until the message runs out. Each stamp lands to the right of anything already cut into that track, so within a track the characters stay in the order they were stamped. When rows is 1 the head never leaves the top track.
The inspector reads the plate one track at a time, top track first, taking each track from left to right. Return the string that reading produces.
Example 1
With two tracks the head alternates on every stamp, so the top track collects the characters at positions 0, 2, 4 and 6 while the bottom track collects those at 1, 3, 5 and 7. Reading the top track and then the bottom track gives QituueHm.
Example 2
A full swing across four tracks takes six stamps, so the head is back on the top track at positions 0, 6 and 12, giving it E, E and A. Track 1 gathers positions 1, 5, 7, 11 and 13, and the two lower tracks follow beneath.
Example 3
With a single track the head never moves off it, so the plate reads exactly like the message.
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 engrave_transcript(message: str, rows: int) -> str:public String engraveTranscript(String message, int rows)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.