摘要: Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ],... 阅读全文
posted @ 2015-03-17 21:57 匡子语 阅读(194) 评论(0) 推荐(0)
摘要: Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ... 阅读全文
posted @ 2015-03-17 17:33 匡子语 阅读(175) 评论(0) 推荐(0)
摘要: 做太多遍了,秒杀。class Solution {public: int hammingWeight(uint32_t n) { int num = 0; for(;n; n &=(n-1), num++); return num; }}; 阅读全文
posted @ 2015-03-17 16:59 匡子语 阅读(182) 评论(0) 推荐(0)
摘要: Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.思路:不能用额外空间,就用矩阵的第一行和第一列来标记这一行或这一列是否需要置0. 用两个bool量记录第一行和第一列是否需... 阅读全文
posted @ 2015-03-17 16:53 匡子语 阅读(231) 评论(0) 推荐(0)