发布时间:2013-04-12 00:06:22
链接:http://leetcode.com/onlinejudgePalindrome PartitioningGiven a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [ ["aa","b.........【阅读全文】
发布时间:2013-04-10 21:12:14
链接:http://leetcode.com/onlinejudgeAdd Two NumbersYou are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.Input: (2 -> 4 -.........【阅读全文】
发布时间:2013-04-08 23:14:11
尝试总结一下const关键词在C++中的用法,不一定全面和正确,希望大家拍砖,共同进步。1、替换#define用const可以在编译阶段进行type检查,避免不必要的错误点击(此处)折叠或打开const int size = 100; //编译器可能会把size放在symbol table里面,而不分配变量内存int arra.........【阅读全文】
发布时间:2013-04-03 22:18:10
原题:http://poj.org/problem?id=1159思路:这个问题其实等价于 求原来字符串 和 反向字符串最小编辑距离。只是操作只有 删除、插入和copy。删除: cost = 1插入: cost = 1copy: cost = 0cost[i][j] = min {cost[i-1][j] + 1, cost[i][j-1] + 1} &.........【阅读全文】
发布时间:2013-04-03 21:03:53
原题:http://poj.org/problem?id=1015思路:|D-P|尽可能的小,而D+P尽可能的大。显然|D-P|是没有最优子结构的,但是 0<=D,P<=20,而 1<=M<=20,所以可以枚举|D-P|的值,-400<=D-P<=400,所以可以用数组 state[M+1][801]记录所以的情况。每来一个候选人,更新所有的记录和路径,D+P根据题目要求是有最优结构的。.........【阅读全文】