码迷,mamicode.com
首页 >  
搜索关键字:__next__    ( 15001个结果
POJ 3373 Changing Digits 好蛋疼的DP
一开始写的高位往低位递推,发现这样有些时候保证不了第四条要求。于是又开始写高位往低位的记忆化搜索,又发现传参什么的蛋疼的要死。然后又发现高位开始的记忆化搜索就是从低位往高位的递推呀,遂过之。 dp[i][j]记录在i位 且 余数为j时的最优解情况。 dp[i][j].next表示当前的最优解是由哪一种状态转移过来的。 代码又写锉了。。 #include #include #includ...
分类:其他好文   时间:2014-06-10 18:08:31    阅读次数:222
【leetcode】sort list
问题:对链表进行排序,要求时间复杂度为NlogN。归并排序。 inline ListNode* getMidle(ListNode *head){ if(NULL == head || NULL == head->next) return head; ListNode *pslow = head; ListNode *pfast = head; while (pfast->next...
分类:其他好文   时间:2014-06-10 17:35:56    阅读次数:282
jQuery 之 setTimeout 传递字符串参数报错
当你打算调用一些jQuery代码显示隐藏的一个元素,并调用setTimeout()在一段延时之后设置其HTML的内容: 整个页面的代码是这样的. show next yes,I am the next function showNext(text){ setTimeout("$('#log').show().text(text)",1000); } .show...
分类:Web程序   时间:2014-06-10 13:26:58    阅读次数:196
hust 1260 Dominos && hust 1516 Dominos
题目描述Dominos are lots of fun. Children like to stand the tiles on their side in long lines. When one domino falls, it knocks down the next one, which k...
分类:其他好文   时间:2014-06-10 12:08:55    阅读次数:232
改进版KMP模式匹配算法
背景朴素匹配算法太低效了。冗余过多,已经比较过的,没必要重复;可以从比较结果中推导出来的,也没必要再重复。核心主串不回溯,变化要匹配的串的下一次比较的位置。实现两个函数,一个提供next数组,即存储要匹配的串的每一个元素匹配失败后,下一次要比较的位置的数组。另一个实现匹配。java代码public ...
分类:其他好文   时间:2014-06-10 11:32:20    阅读次数:239
【leetcode】Next Permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest possible...
分类:其他好文   时间:2014-06-10 10:52:42    阅读次数:192
[LeetCode] Copy List with Random Pointe
题目的关键是要让新链表和原有链表发送关联,可以通过这种关联来设置新链表的random pointer思路:将新链表的元素插入到原有链表元素的后面,如下图所示,就可以根据原有链表的radom->next 就是新链表的random指针所以分3步骤:1 新元素插入2 设置新链表的random3 拆分大链表...
分类:其他好文   时间:2014-06-09 17:59:33    阅读次数:202
求单链表的中间节点,用快慢指针
Node* findMid(Node* &head){ if(head == NULL||head->next == NULL) return head; Node* p = head; Node* q = head; while(q->next->ne...
分类:其他好文   时间:2014-06-09 17:55:34    阅读次数:204
逆序单链表
#include using namespace std;struct Node{ Node *next; int elem;};void creatList(Node* &head){ head = new Node; int elem; cin>>elem; ...
分类:其他好文   时间:2014-06-09 17:50:43    阅读次数:219
【HDOJ】1686 Oulipo
kmp算法。 1 #include 2 #include 3 4 char src[10005], des[1000005]; 5 int next[10005], total; 6 7 void kmp(char des[], char src[]){ 8 int ld = str...
分类:其他好文   时间:2014-06-09 17:46:37    阅读次数:264
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!