1 package leetcode; 2 /* * 3 * 注意问题: 4 * 1. 原序列升序、降序问题,两种情况都要考虑 5 * 2. 边界问题,如果只有两个元素时要单独考虑,在num[mid]==num[left]判断中考虑 6 * 3. 采用2叉查找的思想 7 * */ 8 p...
分类:
其他好文 时间:
2014-11-17 00:19:52
阅读次数:
223
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted fr...
分类:
其他好文 时间:
2014-11-17 00:17:02
阅读次数:
215
题目:Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.思路:我的第一个想法是将lists中的链表两两合并排序,这样时间复杂度是o(n),n为所有链表中的数据...
分类:
其他好文 时间:
2014-11-16 18:31:00
阅读次数:
209
Skip List | Set 1 (Introduction)Can we search in a sorted linked list in better than O(n) time?The worst case search time for a sorted linked list is ...
分类:
其他好文 时间:
2014-11-16 15:49:53
阅读次数:
173
Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, retu...
分类:
其他好文 时间:
2014-11-16 14:38:00
阅读次数:
175
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-11-16 08:14:58
阅读次数:
196
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example,Given 1->2...
分类:
其他好文 时间:
2014-11-16 08:14:02
阅读次数:
220
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...
分类:
其他好文 时间:
2014-11-16 08:12:43
阅读次数:
145
Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3,...
分类:
其他好文 时间:
2014-11-16 08:11:30
阅读次数:
220
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for...
分类:
其他好文 时间:
2014-11-16 08:11:04
阅读次数:
178