实现快读排序算法的关键在于先在数组中选择一个数字,接下来把数组中的数字分为两部分,比所选数字小的移到左半部分,比选择的数字大的移到右边,具体的实现代码如下:
#include
#include
#include
void swap(int *a,int *b)
{
int tmp=*a;
*a=*b;
*b=tmp;
}
int Partition(int data[],int n,in...
分类:
编程语言 时间:
2015-03-16 17:47:46
阅读次数:
176
Determine whether an integer is a palindrome. Do this without extra space.(source)判断一个数字是否为回文数,并且不使用额外的存储空间。“回文”是指正读反读都能读通的句子,那么回文数,就很容易理解,就是指一个数正反读的值是相同的。还有一个要求是不要使用额外的存储空间。Hints:
要将一个数的最高位与最低位比较,取出一...
分类:
其他好文 时间:
2015-03-16 17:45:42
阅读次数:
142
判断一个字符串是否是对称的 跳过所有非数字和字母,字母不分大小写 知道函数isalnum和tolower或者toupper就可以做了,两个指针一个指向头,一个指向尾,朝中间靠拢比较 空串是对称的 class Solution {public: bool isPalindrome(string s) ...
分类:
其他好文 时间:
2015-03-16 16:13:52
阅读次数:
150
标题:Palindrome Partitioning通过率:26.3%难度:中等Given a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible pali...
分类:
其他好文 时间:
2015-03-16 16:07:04
阅读次数:
121
--删除表中重复记录大于两条保存两条delete from t_Cht_clm_reg F where F.case_id in (select T.case_id from (select B.* from (select e.* , row_number() over (partition b....
分类:
其他好文 时间:
2015-03-16 15:48:47
阅读次数:
100
输入一个字符串,求出它的子串中最长的回文串。...
分类:
编程语言 时间:
2015-03-15 23:04:26
阅读次数:
165
//快速排序
public class Quick_Sort {
// 排序的主要算法
private int Partition(int[] data, int start, int end)
{
int mid_data = data[end];// 选取最后最个数作为中间值哨兵,从开始进行遍历,每个数与之比较
int index = start; // 记录比哨兵小的数字在...
分类:
编程语言 时间:
2015-03-15 12:30:38
阅读次数:
131
Valid Palindrome问题:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.思路: 简单的数学推导我的代码:publi....
分类:
其他好文 时间:
2015-03-14 15:14:52
阅读次数:
82
Palindrome Partitioning问题:Given a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partiti...
分类:
其他好文 时间:
2015-03-14 13:41:00
阅读次数:
108
Partition List问题:Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should p...
分类:
其他好文 时间:
2015-03-13 22:04:02
阅读次数:
146