CT007

Zigzag Glyph Carving

MediumAcceptance: 0.0%

The Codetikki stonemasons carve messages in zigzag patterns across temple walls. Characters are placed diagonally from top-left to bottom-right until reaching the kth row, then back up, repeating. Given a string and a number of lines k, print the string in zigzag form across k rows.

Example 1:

Input: thisisazigzag 4
Output: t a g h s z a i i i z s g

Example 2:

Input: hello 3
Output: h o e l l

Constraints:

1 <= len(s) <= 1000 1 <= k <= 1000 s consists of lowercase English letters

Tags:

strings simulation
Loading...
Test Cases:No test cases
No test cases available.