码迷,mamicode.com
首页 >  
搜索关键字:valid palindrome    ( 4264个结果
[LeetCode 题解]: Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only n...
分类:其他好文   时间:2014-07-31 16:08:26    阅读次数:283
HDU 1513 Palindrome
题目就是给一个字符串问最少插入多少个字符能让原字符串变为回文字符串。算法:用原串的长度减去原串与翻转后的串的最大公共字串的长度,就是所求答案。 1 //#define LOCAL 2 #include 3 #include 4 #include 5 #include 6 using name...
分类:其他好文   时间:2014-07-31 12:24:36    阅读次数:220
LeetCode : valid parentheses
解法:用栈,注意栈的用法和switch的用法 1 class Solution { 2 public: 3 bool isValid(string s) { 4 5 stack istack; 6 string::iterator p=s.b...
分类:其他好文   时间:2014-07-31 12:12:46    阅读次数:229
HDU 3068 最长回文 Manacher算法
Manacher算法是个解决Palindrome问题的O(n)算法,可以说是个超级算法了,秒杀其他一切Palindrome解决方案,包括复杂的后缀数组。 网上很多解释,这里总结一下思想重点: 1 原字符串的字符间插入新的字符, 如#,方便统一所有的字符中心,比如aa和aba的字符中心不一样的,aa的字符中心可以说是aa,而aba的中心则是b,而插入#之后,aa成#a#a#,其中...
分类:其他好文   时间:2014-07-31 03:04:15    阅读次数:224
Multi-processor having shared memory, private cache memories, and invalidate queues having valid bits and flush bits for serializing transactions
Multi-processor systems are often implemented using a common system bus as the communication mechanism between CPU, memory, and I/O adapters. It is al...
分类:其他好文   时间:2014-07-31 02:17:25    阅读次数:432
codeforces159D - Palindrome pairs 二重DP
题意:给你一个字符串,问你其中不重叠的回文字串对有多少解题思路:这题用到两种方法,不过其实是一个很巧妙的二重dp1)暴力求解以i开头,j结尾的是否为回文,如果是,ans += sum[i-1](ans 为答案, sum[i]为在 1 - i内回文串的个数--需要dp求解)这里非常耗时,时间大约为 n...
分类:其他好文   时间:2014-07-30 20:05:44    阅读次数:276
POJ 1159 Palindrome(lcs加滚动数组)
lcs算法 加 滚动数组 注释详...
分类:其他好文   时间:2014-07-30 12:23:53    阅读次数:269
Word Break II leetcode java
题目:Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all suc....
分类:编程语言   时间:2014-07-30 03:19:32    阅读次数:341
UVa 401 Palindromes(字符串,回文)
Palindromes  A regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string "ABCDEDCBA" is a palindrome because it is the same when t...
分类:其他好文   时间:2014-07-29 21:57:12    阅读次数:308
[LeetCode] Palindrome Partitioning II (DP)
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 ...
分类:其他好文   时间:2014-07-29 13:43:58    阅读次数:223
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!