摘要: Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4, 200, 1, 3, 2],The longest ... 阅读全文
posted @ 2014-06-16 15:51 穆穆兔兔 阅读(159) 评论(0) 推荐(0) 编辑
摘要: There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be ... 阅读全文
posted @ 2014-06-16 14:15 穆穆兔兔 阅读(295) 评论(0) 推荐(0) 编辑
摘要: Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to... 阅读全文
posted @ 2014-06-16 10:19 穆穆兔兔 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 二分 : 判断条件 当a[left] = A[low]) ,low~mid 二分,mid~high 递归第二种 / / / / / / 条件:(A[mid] A[mid])12 return binarySearch(A,... 阅读全文
posted @ 2014-06-15 15:37 穆穆兔兔 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 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 s... 阅读全文
posted @ 2014-06-14 14:52 穆穆兔兔 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 本文参考基数排序http://hxraid.iteye.com/blog/648532桶排序 http://hxraid.iteye.com/blog/647759基于比较的排序http://hxraid.iteye.com/blog/646760 阅读全文
posted @ 2014-06-14 11:27 穆穆兔兔 阅读(129) 评论(0) 推荐(0) 编辑
摘要: Follow up for ”Remove Duplicates”: What if duplicates are allowed at most twice?For example, Given sorted array A = [1,1,1,2,2,3],Your function should... 阅读全文
posted @ 2014-06-14 11:03 穆穆兔兔 阅读(212) 评论(0) 推荐(0) 编辑
摘要: Given a sorted array, remove the duplicates in place such that each element appear only onceand return the new length.Do not allocate extra space for ... 阅读全文
posted @ 2014-06-14 10:51 穆穆兔兔 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 1 迭代,重要关系 p->right = s.top(); 1 class flat{ 2 public: 3 void flatten(TreeNode* root) { 4 if (root == NULL) return; 5 ... 阅读全文
posted @ 2014-06-14 10:38 穆穆兔兔 阅读(177) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For exa... 阅读全文
posted @ 2014-06-12 11:13 穆穆兔兔 阅读(141) 评论(0) 推荐(0) 编辑