These two questions is essentially a question, are generates print matrix or spiral
Topic analysis
I was beginning to realize each row or each column a few prints, leaving the next column or the next line treatment, this has led finally, a special judge in the end is the remaining 1 row / column, or two rows / columns. The code does not result in an extremely elegant, although AC. I think the goal is not just brush leetcode AC, but also to the pursuit of time / space complexity, and elegant code. Read overwhelmingly answer disscuss area, each is a simple "cut" rows or columns can be very elegant solution out. As Spiral Matrix II but more simply, the subject of the request is to generate a square spiral, it is possible to almost completely code reuse.