[leetcode]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 0, 1, and 2 to represent the color red, white, and...
分类:
其他好文 时间:
2014-09-18 13:21:43
阅读次数:
164
Here is the basic algorithm about merge sort:def merge(s1,s2,s): i=j=0 while i + j < len(s): if j == len(s2) or (i < len(s1) and s1[i] < ...
分类:
编程语言 时间:
2014-09-18 11:17:13
阅读次数:
165
我比较了一下sort和一个自己写的o(n)的程序的运行时间。惊奇发现sort的速度几乎和直接用python写的o(n)的程序运行时间接近先上代码sort的测试代码import randomimport syslen_test_arr = int(sys.argv[1])test_arr = [ran...
分类:
编程语言 时间:
2014-09-18 09:39:33
阅读次数:
228
Sort a linked list in O(n log n) time using constant space complexity.记得Insert Sort List, 那个复杂度是O(N^2)的,这里要求O(nlogn),所以想到merge sort, 需要用到Merge Two Sor...
分类:
其他好文 时间:
2014-09-18 01:57:43
阅读次数:
199
1 package sort; 2 3 import java.util.ArrayList; 4 import java.util.Random; 5 6 public class Sort 7 { 8 9 public static Random r = new...
分类:
其他好文 时间:
2014-09-17 21:51:22
阅读次数:
368
1.sed-n‘/^12:3*/,/^13:3*/p‘a.log这个截取的时间段是12:00到13:00(刚开始我以为这个截取的时间段是12点30到13点30的,因为我把*当成通配符了,q其实在sed和awk中它是正则表达式)2.sed-n‘/^12:30*/,/^13:30*/p‘a.log这个截取的时间段是12:30到13:30比如像awk,sed,等,是针对..
分类:
其他好文 时间:
2014-09-17 18:55:43
阅读次数:
266
Ubuntu监控load脚本:#viload.sh按a或i进入编辑模式#!/bin/bashName=`hostname`IP=`/sbin/ifconfigeth0|grep"inetaddr"|awk-F[:""]+‘{print$4}‘`Date=`date+%m%d%y`Load=`/usr/bin/uptime|grepload|awk-F[:""]+‘{print$14}‘|tr-d","`Load2=150if[$(echo"$Load>$Load2"|bc)-e..
分类:
其他好文 时间:
2014-09-17 18:51:43
阅读次数:
224
#!/bin/bash
loglast=`cat/var/lib/mysql/localhost-bin.index|awk-F"/"‘{print$2}‘|tail-n1`//取出正在使用binlog日志
if[!-e/binlogdir];then
mkdir/binlogdir
fi
foriin`cat/var/lib/mysql/localhost-bin.index|awk-F"/"‘{print$2}‘`//遍历所有的binlog日志
do
logna..
分类:
其他好文 时间:
2014-09-17 18:51:23
阅读次数:
252
make_heap原型:
std::make_heap
default (1)
template
void make_heap (RandomAccessIterator first, RandomAccessIterator last);
custom (2)
template
void make_heap (Rando...
分类:
其他好文 时间:
2014-09-17 18:43:42
阅读次数:
241
$_sql1 = "SELECT * FROM tb_GoodsInfo"; $_result1 = _query($_sql1); $_rows1 = _num_rows($_result1); $_sort = $_rows1 + 1;
分类:
其他好文 时间:
2014-09-17 14:47:22
阅读次数:
182