StringsAnother useful data type is thestring. Astringcan contain letters, numbers, and symbols.Strings need to be within quotes.Escaping charactersbac...
分类:
其他好文 时间:
2014-10-06 12:58:10
阅读次数:
171
[leetcode]Given a string s, partition s such that every substring of the partition is a palindrome....
分类:
其他好文 时间:
2014-10-06 12:19:50
阅读次数:
200
【leetcode】Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s....
分类:
其他好文 时间:
2014-10-06 12:12:00
阅读次数:
149
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possibl...
分类:
其他好文 时间:
2014-10-06 09:11:40
阅读次数:
165
题目地址:Ural 1586
先定义一个prime三维数组来记录素数,若i*100+j*10+k为素数,则标记prime[i][j][k]为1,否则为0.这样对后面的处理很方便。
然后定义一个dp三维数组,dp[n][i][j]表示当前n位的十位数字为i,个位数字为j时的素数个数,这时候状态要从prime[k][i][j]为素数时转移过来,所以状态转移方程为:
if(prime[j][k][...
分类:
其他好文 时间:
2014-10-06 02:31:19
阅读次数:
175
You 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 ...
分类:
其他好文 时间:
2014-10-05 23:28:39
阅读次数:
357
struct Node{
int index;
int value;
};
bool compare(Node a, Node b)
{
return a.value < b.value;
}
class Solution {
public:
vector twoSum(vector &numbers, int target) {
...
分类:
其他好文 时间:
2014-10-05 22:56:39
阅读次数:
252
Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-nega...
分类:
其他好文 时间:
2014-10-05 20:05:58
阅读次数:
208
Given a set of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Thesamerepeated num...
分类:
其他好文 时间:
2014-10-05 16:48:38
阅读次数:
193
题目大意:给出一个字符串,问至少添加多少个字符才能使它成为回文串?思路:很明显的方程是:dp[i][j]=min{dp[i+1][j],dp[i][j-1],dp[i+1][j-1](str[i]==str[j]时)}dp[i][j]表示第i个字符到第j个字符构造成回文串最少添加的字符,但discu...
分类:
其他好文 时间:
2014-10-05 14:40:18
阅读次数:
188