摘要: 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:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]You should return [1,2,3,6,9,8,7,4,5]. 注意几点: 1)spiral 总共转了几圈 2) 最后一圈的时候如果是“横”“竖”需要处理好边界class Solution {public: ve... 阅读全文
posted @ 2013-08-01 15:23 冰点猎手 阅读(209) 评论(0) 推荐(0)
摘要: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. 很挫的一个想法: 使用O(M+N)的spaceclass Solution {public: void setZeroes(vector > &matrix) { // Start typing your C/C++ solution below // DO NOT write int main() function int m = matrix.size()... 阅读全文
posted @ 2013-08-01 11:55 冰点猎手 阅读(251) 评论(0) 推荐(0)