The TransCompilator

Solved LeetCode program · 370 of 1,000

#0498 · Diagonal Traverse

Medium Array chunk-08.md

Original English source

Keep a shared matrix holding 1, 2, 3, 4, 5, 6, 7, 8, and 9. Keep a shared starts holding 0, 0, 2, 1, and 2. Keep a shared order as an empty list of whole numbers. Keep a shared rising of 0.
To seek from band (a whole number) with column (a whole number). If band is less than 0, return. If band is more than 2, return. If column is less than 0, return. If column is more than 2, return. Place item (band times 3 plus column) of matrix into order. If rising is 1, seek from band minus 1 with column plus 1. If rising is 0, seek from band plus 1 with column minus 1.

For every diagonal from 0 to 4.
The band is item diagonal of starts. The column is diagonal minus band. Set rising to 1 minus diagonal modulo 2. Seek from band with column.

For each value in order, show value.

Open in Playground Browse all 1,000 problems

Expected stdout

1
2
4
7
5
3
6
8
9