
Sort
文章平均质量分 76
豆腐脑是咸的
这个作者很懒,什么都没留下…
展开
-
Maximum Gap (Java)
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-01-31 10:32:02 · 1799 阅读 · 0 评论 -
Merge Intervals (Java)
Given a collection of intervals, merge all overlapping intervals. For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18]. Source public List merge(List interva原创 2015-02-06 16:04:19 · 394 阅读 · 0 评论 -
Largest Number (Java)
Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330. Note: The result may be ve原创 2015-01-20 11:02:10 · 713 阅读 · 0 评论 -
Insert Interval (Java)
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according to their start times. E原创 2015-02-06 19:53:47 · 496 阅读 · 0 评论 -
Sort List (Java)
Sort a linked list in O(n log n) time using constant space complexity. 学习了网上的帖子,用归并排序,注意空间复杂度超了,记得重做 Source /** * Definition for singly-linked list. * class ListNode { * int val; * Li原创 2015-01-01 14:30:09 · 316 阅读 · 0 评论 -
Insertion Sort List (Java)
Sort a linked list using insertion sort. 写的有点乱,有时间再写一遍 Source /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { *原创 2015-01-02 20:11:29 · 330 阅读 · 0 评论 -
Sort Colors (Java)
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the integers原创 2015-01-02 21:39:31 · 326 阅读 · 0 评论