Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2-...
分类:
其他好文 时间:
2014-07-07 16:17:00
阅读次数:
139
前言今天学学习NH这个框架,在新增对象的时候,看见大神用了persist而没有用Save,心中比较疑惑,查阅资料的时候,发现这篇写的非常不错,转载供大家参考。hibernate的保存hibernate对于对象的保存提供了太多的方法,他们之间有很多不同,这里细说一下,以便区别:一、预备知识:在所有之前...
分类:
系统相关 时间:
2014-07-07 15:15:51
阅读次数:
515
题目:Merge Two Sorted ListsMerge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the ...
分类:
其他好文 时间:
2014-07-07 14:06:19
阅读次数:
221
Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?
分类:
其他好文 时间:
2014-07-07 13:07:00
阅读次数:
153
Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?
分类:
其他好文 时间:
2014-07-03 11:51:05
阅读次数:
117
var indexOfSorted = function f(arr,n){
//assume : arr has been sorted
var low = 0;
var high = arr.length - 1;
var mid = (low + high) / 2;
while(high - low > 1){
if(n == arr[low]){return low...
分类:
Web程序 时间:
2014-06-30 08:54:10
阅读次数:
978
最近公司产品需要增加一个功能,就是版本自动更新,使用apt-get 实现。apt-get 软件源配置的方法,参见本人资源里的共享。下面是代码中作为升级的一部分。 FILE *fp;
char buffer[256];
char source_ok[] = "Reading package lists...";
if(0 > system("mv -f /etc/apt/sources....
分类:
其他好文 时间:
2014-06-30 08:37:47
阅读次数:
228
快速排序使用分治法(Divide and conquer)策略来把一个串行(list)分为两个子串行(sub-lists)。
步骤为:
1,从数列中挑出一个元素,称为 "基准",
2,重新排序数列,所有元素比基准值小的摆放在基准前面,所有元素比基准值大的摆在基准的后面(相同的数可以到任一边)。在这个分区退出之后,该基准就处于数列的中间位置。这个称为分区操作。
3,递归地把小于基准值元素的子数列和大于基准值元素的子数列排序。
4,递归的最底部情形,是数列的大小是零或一,也就是永远都已经被排序好了。虽然一直递...
分类:
编程语言 时间:
2014-06-30 08:19:12
阅读次数:
203
题目链接:http://poj.org/problem?id=2299
题目大意:求出排序过程中的最小交换次数
利用归并排序的分治算法解决此题。
代码:
#include
#include
#include
#define N 500001
using namespace std;
int a[N];
int temp[N];
long long ans;
void merge(in...
分类:
其他好文 时间:
2014-06-30 08:18:11
阅读次数:
230
题目
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time
complexity should be O(log (m+n)).
方法
转换为寻找第k大的数。
...
分类:
其他好文 时间:
2014-06-30 06:05:58
阅读次数:
261