Median of Two Sorted ArraysThere are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run...
分类:
其他好文 时间:
2014-08-08 17:33:46
阅读次数:
232
http://www.geeksforgeeks.org/amazon-interview-set-108-campus/F2F-1:1) Given a sorted circular link list and a pointer to random node, now insert a new...
分类:
其他好文 时间:
2014-08-08 04:18:25
阅读次数:
248
问题:找出某个元素的位置朴素的暴力方法class Solution {public: int search(int A[], int n, int target) { int i; for(i=0;i<n;i++) { if(A[...
分类:
其他好文 时间:
2014-08-06 21:45:42
阅读次数:
196
问题:消除数组中重复次数超过三次的多余的数分析:若ai-1==ai-2若ai也相等,则清楚aiclass Solution {public: int removeDuplicates(int A[], int n) { int i,j; for(i=2;i<n;i+...
分类:
其他好文 时间:
2014-08-06 21:41:52
阅读次数:
199
Suppose a sorted array is rotated at some pivot unknown to you beforehand.
(i.e., 0 1 2 4 5 6 7 might become 4
5 6 7 0 1 2).
You are given a target value to search. If found in the array retur...
分类:
其他好文 时间:
2014-08-05 00:48:58
阅读次数:
248
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...
分类:
其他好文 时间:
2014-08-05 00:24:38
阅读次数:
281
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.方法:为了使BST高度平衡,要找链表中的中值作为当前根节点。/** * Defin...
分类:
其他好文 时间:
2014-08-04 20:37:47
阅读次数:
194
题目: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 shou....
分类:
编程语言 时间:
2014-08-04 13:24:27
阅读次数:
256
问题:将有序的数组中重复的数字去掉分析:由于有序所以只用和前一个比较就行class Solution {public: int removeDuplicates(int A[], int n) { int i,j; if(n==0 || n==1) return n...
分类:
其他好文 时间:
2014-08-03 17:42:35
阅读次数:
204
Corner cases!class Solution {public: ListNode *deleteDuplicates(ListNode *head) { if (!head) return head; if (!head->next) return hea...
分类:
其他好文 时间:
2014-08-03 07:51:34
阅读次数:
237