#include
#include
using namespace std;
int Set[1000];
void merge2(int a,int b)
{
if(a<b) Set[b]=a;
else Set[a]=b;
}
int find2(int x)
{
int r=x;
while(Set[r]!=r) r=Set[r];
return r;...
分类:
其他好文 时间:
2015-07-11 12:11:01
阅读次数:
106
Given a collection of numbers, return all possible permutations.For example,[1,2,3]have the following permutations:[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,...
分类:
其他好文 时间:
2015-07-11 12:07:21
阅读次数:
117
大多数flex程序有二义性,相同的输入可能被多种模式匹配flex通过下面2个规则来解决匹配尽可能长的字符如果2个模式都可以匹配, 匹配更早出现的那个模式例子"+" { return ADD; }"=" { return ASSIGN; }"+=" { return ASSIGNADD; }"if" ...
分类:
其他好文 时间:
2015-07-11 10:24:39
阅读次数:
159
void FindNumsAppearOnce(int data[], int length, int* num1, int* num2)
{
if (data == NULL || length
return;
int resultExclusiveOR = 0;
for (int i = 0; i
resultExclusiveOR ^= data[i];
unsigned ...
分类:
编程语言 时间:
2015-07-11 09:18:58
阅读次数:
251
void Reverse(char* pBegin, char* pEnd)
{
if (pBegin == NULL || pEnd == NULL)
return;
while (pBegin
{
char temp = *pBegin;
*pBegin = *pEnd;
*pEnd = temp;
pBegin++, pEnd--;
}
}
char*...
分类:
其他好文 时间:
2015-07-11 09:17:52
阅读次数:
187
Given a set of distinct integers, nums, return all possible subsets.
Note:
Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.
For ...
分类:
其他好文 时间:
2015-07-11 09:16:34
阅读次数:
150
最近在学习shell编程,文中若有错误的地方还望各位批评指正。先来看一个简单的求和函数#!/bin/bash
#a test about function
f_sum 7 8
function f_sum(){
return $(($1+$2));
}
f_sum 3 5;
total=$(f_sum 3 6);
echo $total,$?;注意几个问题:
1.shell是逐行执行,所以要...
分类:
系统相关 时间:
2015-07-11 09:15:02
阅读次数:
167
Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters '
', return the length of last word in the string.
If the last word does not exist...
分类:
其他好文 时间:
2015-07-11 09:13:11
阅读次数:
106
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.
For example,
If n = 4 and k = 2, a solution is:
[
[2,4],
[3,4],
[2,3],
[1,2],
[1,3],
[1,4...
分类:
其他好文 时间:
2015-07-11 09:11:50
阅读次数:
107
/** * 异或加密 * * @param strOld * 源字符串 * @param strKey * 密钥 * @return 加密后的字符串 */ public stat...
分类:
编程语言 时间:
2015-07-11 07:55:06
阅读次数:
126