码迷,mamicode.com
首页 >  
搜索关键字:__next__    ( 15001个结果
CC150 - 11.2
Question:Write a method to sort an array of strings so that all the anagrams are next to each other. 1 package POJ; 2 3 import java.util.Arrays; 4 im....
分类:其他好文   时间:2014-08-20 02:41:34    阅读次数:199
009实现一个算法来删除单链表中的一个结点,只给出指向那个结点的指针(keep it up)
呵呵,这个题不能直接删除已知的结点,因为是单链表,不知道前驱,只知道 后继结点,直接删除会使链表断开。不过我们可以删除已知结点的后继结点, 把后继结点的值赋值给已知结点。 #include struct Node { int data; Node* next; }; bool removeNode(Node* vNode) { if (vNode == NULL || vNo...
分类:其他好文   时间:2014-08-20 01:25:45    阅读次数:174
Exercise DS
#include using namespace std;typedef struct Node{ Node *next; int data;}Node, *List;typedef struct DNode{ DNode *prior; DNode *next; in...
分类:其他好文   时间:2014-08-20 01:16:55    阅读次数:346
实现一个可迭代的类
可迭代的类实现一个可迭代的类,需要在类里面定义两种方法:1. __iter__():返回iterator对象本身2. next():每当next()方法被调用时,返回下一个值,直到抛出StopIteration的异常 1 class Fabonacci(object): 2 """Fabon...
分类:其他好文   时间:2014-08-19 23:44:05    阅读次数:191
Trie树 模板
typedef struct node{ int count; struct node *next[MAX];}Trie;Trie *Newnode()//建立结点&初始化a{ int i; Trie *T; T = (Trie *)malloc(sizeof(Trie...
分类:其他好文   时间:2014-08-19 20:39:25    阅读次数:169
邻接表 - 边表
我对边表的理解和边表的建立://结构struct node{ int u,v,w; int next;}g[M];int head[N],t = 0;//初始化void init(){ t = 0; memset(head,-1,sizeof(head));}//加边void...
分类:其他好文   时间:2014-08-19 20:32:05    阅读次数:287
Map集合的四种遍历方式
Map map = new HashMap();for (int i = 0; i > iter = map.entrySet().iterator();while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); ...
分类:其他好文   时间:2014-08-19 14:09:34    阅读次数:245
POJ 2752 深刻理解KMP失配指针
思路:刚开始还在想怎么做,虽然以前是理解了失配指针的用处,但是确实不知道失配指针还有如此用处,其实还有很多用处,我用得少了不懂而已。 比如:         i   0  1  2  3  4  5   6  7  8  9  10 11      p[i]  A  B R A  C  A  D  A  B  R  A  无 next[i]  0  0  0  0  1  0   1  0...
分类:其他好文   时间:2014-08-19 12:58:05    阅读次数:181
实现一个算法从一个单链表中返回倒数第n个元素(keep it up)
我们维护两个指针, 它们之间的距离为n。然后,我将这两个指针同步地在这个单链表上移动,保持它们的距离 为n不变。那么, 当第二个指针指到空时,第一个指针即为所求。 #include struct Node { int data; Node* next; }; void initList(Node* vNode) { for (int i=0; i < 20; ++i) {...
分类:其他好文   时间:2014-08-19 01:00:33    阅读次数:257
Next Permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possibl...
分类:其他好文   时间:2014-08-19 00:57:53    阅读次数:213
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!