Min Li's Note
KVM,QEMU, X86 virtualization
Pages
Home
Collection
About
Wednesday, October 15, 2014
Spiral Matrix
Problem
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.
For example,
Given the following matrix:
You should return [1,2,3,6,9,8,7,4,5].
Idea
细节实现题,没什么好办法,就是一圈一圈的往result里压
对于行数m,列数n, 总圈数是(min(n,m)+1) / 2
Solution
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment