My Blog List

[Leetcode Solution] Spiral Matrix II

Analysis 

  • Using the given strategy filing the blanks one by one
  • Each time fill one blank, then use a direction to find the next blank which needs to be filled. If it is a legal blank, then go ahead. Else change the direction and do the above again.

Note

  • The direction can be represented by a array.
  • Change direction can be represented by mod operation

Code


No comments:

Post a Comment

Enter you comment