My Blog List

[Leetcode Solution]Spiral Matrix

Analysis 

  • Just visited all the nodes in the matrix in a given order and print them
  • Use a variable dir to represent the current direction used to find the next node. If the next node is not valid, change direction and do it again.

Note

Code


No comments:

Post a Comment

Enter you comment