For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decre...
分类:
其他好文 时间:
2015-02-19 12:54:32
阅读次数:
138
LeetCode[Sort]: Largest Number
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 953433...
分类:
其他好文 时间:
2015-02-17 21:08:13
阅读次数:
215
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-02-17 14:08:08
阅读次数:
165
概述很多java 方法 会使用函数式接口作为参数。例如,java.util.Arrays类中的一个sort方法,就接受一个Comparator接口,它就是一个函数式接口,sort方法的签名如下:public static T[] sort(T[] array, Comparator comparat...
分类:
编程语言 时间:
2015-02-16 18:19:15
阅读次数:
186
一、Arrays类常用方法二、简单例子package com.pb.demo1;import java.util.Arrays;/* * Arrays工具类的中的几个常用方法 * 1.copyof * 2.toString * 3.equals * 4.sort * 5.fill * 6.binar...
分类:
编程语言 时间:
2015-02-16 15:33:36
阅读次数:
192
标题:Sort List通过率:21.3%难度:中等Sort a linked list inO(nlogn) time using constant space complexity.本题就是一个排序的问题,但是是针对单向链表去处理,那么问题关键就是怎么去处理链表,时间复杂度为nlogn,所以可以...
分类:
其他好文 时间:
2015-02-16 11:41:43
阅读次数:
146
Given any permutation of the numbers {0, 1, 2,..., N-1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation tha...
分类:
其他好文 时间:
2015-02-16 08:58:45
阅读次数:
188
归并排序(Merge sort)是创建在归并操作上的一种有效的排序算法。该算法是采用分治法(Divide and Conquer)的一个非常典型的应用。算法描述:将待排序数据分为两部分(递归调用归并排序)。对两部分数据进行归并操作。时间复杂度:T(N) = 2 * T(N/2) + cN = 2.....
分类:
编程语言 时间:
2015-02-16 00:22:14
阅读次数:
267
Sort a linked list in O(n log n) time using constant space complexity.
可以利用归并排序解决该问题。普通的归并排序算法时间复杂度为O(nlogn),空间复杂度为O(n),因为需要建立两个数组来存储原来数组的值,这两个数组的长度加起来恰好为原数组的长度。但是对于链表可以省去复制两个已经排好序的数组的操作,从而使空间复杂度...
分类:
其他好文 时间:
2015-02-15 23:08:39
阅读次数:
175
根据《数据结构与算法分析——Java语言描述》一书的顺序来总结的。插入排序(insertion sort)希尔排序(Shellsort)堆排序(heapsort)并归排序(mergesort)快速排序(quicksort)桶式排序(bucketsort)外部排序(external sorting)...
分类:
编程语言 时间:
2015-02-15 21:49:05
阅读次数:
178