Given an unsorted array, find the maximum difference between the successive elements in its sorted form.
Try to solve it in linear time/space.
Return 0 if the array contains less than 2 elements. ...
分类:
其他好文 时间:
2015-02-05 09:38:18
阅读次数:
271
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, return 1->2->3.
定义一个pre 和cur
1.当二者...
分类:
编程语言 时间:
2015-02-05 09:34:25
阅读次数:
189
Binary search is a famous question in algorithm.For a given sorted array (ascending order) and a target number, find the first index of this number in...
分类:
其他好文 时间:
2015-02-05 07:02:22
阅读次数:
91
题目链接:Search in Rotated Sorted Array
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 sear...
分类:
其他好文 时间:
2015-02-04 23:24:53
阅读次数:
261
题目链接:Search for a Range
Given a sorted array of integers, find the starting and ending position of a given target value.
Your algorithm's runtime complexity must be in the order of O(log n).
If the...
分类:
其他好文 时间:
2015-02-04 23:24:39
阅读次数:
254
题目链接:Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
You may assume ...
分类:
其他好文 时间:
2015-02-04 23:21:55
阅读次数:
148
思路:
从头开始遍历链表并将结点的引用存储在HashSet中,出现重复的地方就是出现环的地方。...
分类:
其他好文 时间:
2015-02-04 20:25:04
阅读次数:
152
https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?...
分类:
其他好文 时间:
2015-02-04 20:15:06
阅读次数:
109
Given a non-overlapping interval list which is sorted by start point.
Insert a new interval into it, make sure the list is still in order and non-overlapping (merge intervals if necessary).
Exam...
分类:
其他好文 时间:
2015-02-04 18:45:28
阅读次数:
152
【题目】
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 from left to right.The first integ...
分类:
其他好文 时间:
2015-02-04 16:43:23
阅读次数:
124