Diagonal Traverse
Medium · Arrays & Strings · about 20 minutes
Asked at Meta, Oracle, Microsoft, Cisco, Bloomberg, IBM, Arista Networks, Palo Alto Networks, Dell Technologies, Zscaler, Nutanix.
Given an m × n matrix, return all its elements in diagonal zigzag order: the first anti-diagonal goes up-right, the next down-left, and so on, starting from the top-left element.