Meta Variants for Diagonal Traverse (LC1424 & LC498)

2298
Mar 12, 2025
Mar 22, 2025

Hey y’all! Been seeing Meta ask Leetcode 1424 Diagonal Traverse 2 a lot recently (or alternatively, Leetcode 498 Diagonal Traverse 1) so thought I’d go over it and its 2 variants.

I’ve seen the OGs of both be asked but it’s not too common. The variants kinda take over in this one:

  • What if you had to return the anti-diagonal order in a 2D list?
  • What if you had to print the anti-diagonal order?

This one’s a bit tricky and though the BFS solution works, a space complexity solution does exist.

Check it out (or not!):


Reference to the OG LC problem: https://leetcode.com/problems/diagonal-traverse-ii/description/

Good luck on your phone screens & onsite loops.

Comments (1)