The TransCompilator

Solved LeetCode program · 6 of 1,000

#0006 · Zigzag Conversion

Medium String chunk-01.md

Original English source

The source is "PAYPALISHIRING". The rows is 3. The lastrow is rows minus 1. The store is an empty list of text.
For every row from 0 to lastrow.
Place "" into store.

The row is 0. The step is 1. The sourcelast is the last position of source.
For every position from 0 to sourcelast.
Place character position of source into item row of store. If row is 0 and lastrow is more than 0, set step to 1. If row is lastrow and lastrow is more than 0, set step to 0 minus 1. Increase row by step.

The result is join store with "". Show result.

Open in Playground Browse all 1,000 problems

Expected stdout

PAHNAPLSIIGYIR