#include #include #include #include #include #include #include using namespace std;int a[20];void print_permutation(int n, int a[], int cur){ int i...
分类:
其他好文 时间:
2014-07-09 21:55:48
阅读次数:
206
代码注释比较详细:
#include
#include
using namespace std;
struct Node{
int data;
Node* next;
};
Node* head = NULL;
bool create() {
head = (Node*)malloc(sizeof(Node));
if(NULL == head) return false;...
分类:
其他好文 时间:
2014-07-08 21:05:05
阅读次数:
238
迭代对于我们搞Java的来说绝对不陌生。我们常常使用JDK提供的迭代接口进行Java集合的迭代。Iterator iterator = list.iterator();
while(iterator.hasNext()){
String string = iterator.next();
//do something...
分类:
编程语言 时间:
2014-07-08 12:50:53
阅读次数:
290
上周算法班的BEN老师花了1个小时讲自动机和KMP的关系,结果failed...明天又要上课了,花了半天时间看了下KMP,暂且停留在利用next求模式中的跳跃长度,自动机那个还不能理解。。。具体的可以百度阮一峰的KMP算法。看着什么前缀后缀,突然想到上下文无关文法乔姆斯基范式了。。。。又想到了NFA...
分类:
其他好文 时间:
2014-07-06 17:00:42
阅读次数:
170
DescriptionThe cows have purchased a yogurt factory that makes world-famous Yucky Yogurt. Over the next N (1 #includeint min(int a,int b){ if(a>b) ...
分类:
其他好文 时间:
2014-07-06 14:21:54
阅读次数:
215
简单的插入排序,总是超时,暂且放在这记录一下。
class Solution:
# @param head, a ListNode
# @return a ListNode
def insertionSortList(self, head):
if head == None or head.next == None:
return head
psuhead...
分类:
编程语言 时间:
2014-07-06 11:52:20
阅读次数:
230
单链表的反转可以使用循环,也可以使用递归的方式
1.循环反转单链表
循环的方法中,使用pre指向前一个结点,cur指向当前结点,每次把cur->next指向pre即可。
代码:
# include
# include
using namespace std;
struct linkNode
{
int val;
linkNode *next;
linkNode(int...
分类:
编程语言 时间:
2014-07-06 11:08:28
阅读次数:
231
完美数
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 128000/64000 KB (Java/Others)
SubmitStatistic Next
Problem
Problem Description
8是中国人很喜欢的一个数字,但是如果有3的存在就变成了38,就不是很好了。。
你能告诉我,在[L,...
分类:
其他好文 时间:
2014-07-06 10:51:26
阅读次数:
185
可以练习下链表的逆置。
def PrintListReversingly(head):
if head == None:
return
if head:
PrintListReversingly(head.next)
print head.val
def reverse(head):
if head == None or head.next == None:
return...
分类:
其他好文 时间:
2014-07-06 09:29:57
阅读次数:
214
单链表的反转可以使用循环,也可以使用递归的方式
1.循环反转单链表
循环的方法中,使用pre指向前一个结点,cur指向当前结点,每次把cur->next指向pre即可。
代码:
class ListNode:
def __init__(self,x):
self.val=x;
self.next=None;
def nonrecurse(he...
分类:
编程语言 时间:
2014-07-06 00:24:52
阅读次数:
331