Traverse Matrix in Diagonal strips

前端 未结 16 1843
暖寄归人
暖寄归人 2020-11-28 02:55

I thought this problem had a trivial solution, couple of for loops and some fancy counters, but apparently it is rather more complicated.

So my question is, how woul

16条回答
  •  一生所求
    2020-11-28 03:35

    I would shift the rows like so:

    1  2  3  x  x
    x  4  5  6  x
    x  x  7  8  9
    

    And just iterate the columns. This can actually be done without physical shifting.

提交回复
热议问题