/**
* 冒泡排序
* @author fgtian
*
*/
public class BubleSort {
public static void sort(int[] arr) {
int length = arr.length;
for (int i = 0; i i; j...
分类:
其他好文 时间:
2014-08-10 15:46:20
阅读次数:
165
4.留下pid为12345的那个sh进程,杀死系统中所有其它sh进程 ps –ef|grep sh |awk ‘{if($2!=”12345”) {print “kill “$2}}’ >killpid.sh cat killpid.sh ./killpid.sh 5. 根据以下日志文件,计算使用各...
分类:
其他好文 时间:
2014-08-10 15:34:30
阅读次数:
223
package data;public class Sort { String endline = System.getProperty("line.separator"); //选择排序 public void selectSort(int[] arr){ int len = arr.leng.....
分类:
其他好文 时间:
2014-08-10 15:23:50
阅读次数:
209
1通过awk脚本运行awk程序:awk-f program_file_name input_files
#!/bin/awk -f
BEGIN
{
print "What is your name,sir?";
while(getline>0)
print "Hi",$1,"Nice to meet you!"
}
2 FILENAME, FNR
stude...
分类:
其他好文 时间:
2014-08-10 13:03:40
阅读次数:
261
Round 1(Bar Raiser):Complete discussion on my project.Suppose you have a file with billion entries and you have to sort the data of a file according t...
分类:
其他好文 时间:
2014-08-10 08:07:59
阅读次数:
191
说明:归并排序: 时间 O(nlogn),空间 O(1). 每次将链表一分为二, 然后再合并。快排(用两个指针)
说明: 与顺序表不同的时,每次找插入位置时从头开始走。
分类:
其他好文 时间:
2014-08-10 01:40:39
阅读次数:
226
Sort a linked list using insertion sort.思路:若当前元素比head小,插入已排序队列头部;否则,从前往后查找当前元素的插入位置。 1 ListNode *insertionSortList( ListNode *head ) { 2 if( !head...
分类:
其他好文 时间:
2014-08-10 01:30:39
阅读次数:
313
本题就是一题LIS(最长递增子序列)的问题。本题要求求最长递增子序列和最长递减子序列。
dp的解法是O(n*n),这个应该大家都知道,不过本题应该超时了。
因为有O(nlgn)的解法。
但是由于本题的数据特殊性,故此本题可以利用这个特殊性加速到O(n)的解法,其中的底层思想是counting sort分段的思想。就是如果你不会counting sort的话,就很难想出这种优化的算法了。
...
分类:
其他好文 时间:
2014-08-09 23:18:49
阅读次数:
393
Sort a linked list in O(n log n) time using constant space complexity.思路:题目要求O(n log n)的时间复杂度以及常空间复杂度,因此,使用归并排序策略。 1 class Solution { 2 public: 3 ...
分类:
其他好文 时间:
2014-08-09 23:13:19
阅读次数:
284