← Questions

Diagonal traversal of a matrix

0
MetaCodingLast asked Feb 2026

Return the elements of a matrix diagonal by diagonal. In one version the direction alternates (up-right, then down-left); in another every diagonal is read in the same direction and the rows may have different lengths. Be ready for both.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding