摘要: Given an unsorted integer array, find the first missing positive integer. For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2. Your algorithm should run in O(n) time and uses constant space.题意是是说:在正整数的范围里面求第一个缺失的数A[0] = 1 A[1] = 2....A[i] = i+1; 正确的存储.此题目没有好好解答出来。再思考。class Solution {public: 阅读全文
posted @ 2013-07-16 23:23 一只会思考的猪 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 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].//DFS 版本//之后需要设计一个非递归的版本//甚至给定(i,j)推断给定位置的valueclass Solution {public: voi... 阅读全文
posted @ 2013-07-16 23:01 一只会思考的猪 阅读(163) 评论(0) 推荐(0) 编辑