码迷,mamicode.com
首页 >  
搜索关键字:palindrome    ( 1561个结果
Codeforces 486C Palindrome Transformation(贪心)
题目大意:给定一个字符串,长度N,指针位置P,问说最少花多少步将字符串变成回文串。解题思路:其实只要是对称位置不相同的,那么指针肯定要先移动到这里,修改字符只需要考虑两种方向哪种更优即可。然后将所有需要到达的位置跳出来,贪心处理。#include #include #include #include...
分类:其他好文   时间:2014-11-13 01:48:03    阅读次数:136
Codeforces 486C Palindrome Transformation(贪心)
题目链接:Codeforces 486C Palindrome Transformation 题目大意:给定一个字符串,长度N,指针位置P,问说最少花多少步将字符串变成回文串。 解题思路:其实只要是对称位置不相同的,那么指针肯定要先移动到这里,修改字符只需要考虑两种方向哪种更优即 可。然后将所有需要到达的位置跳出来,贪心处理。 #include #include #incl...
分类:其他好文   时间:2014-11-13 00:36:35    阅读次数:216
Palindrome(最长回文串manacher算法)O(n)
PalindromeTime Limit:15000MSMemory Limit:65536KB64bit IO Format:%I64d & %I64uSubmitStatusDescriptionAndy the smart computer science student was attend...
分类:编程语言   时间:2014-11-12 21:00:46    阅读次数:231
poj 3280 Cheapest Palindrome(区间DP)
Cheapest PalindromeTime Limit:2000MSMemory Limit:65536KTotal Submissions:5995Accepted:2922DescriptionKeeping track of all the cows can be a tricky tas...
分类:其他好文   时间:2014-11-11 22:33:09    阅读次数:193
Palindrome Number
Palindrome NumberDetermine whether an integer is a palindrome. Do this without extra space. 1 public class Solution { 2 public boolean isPalindrom...
分类:其他好文   时间:2014-11-09 23:37:34    阅读次数:209
[leetcode] 1. Valid Palindrome
leetcode的第一题,回文数判断。原题如下:For example, "A man, a plan, a canal: Panama" is a palindrome. "race a car" is not a palindrome.Note: Have you consider that t...
分类:其他好文   时间:2014-11-09 19:33:04    阅读次数:300
Uva 11584 - Partitioning by Palindromes dp
Problem H: Partitioning by Palindromes We say a sequence of characters is a palindrome if it is the same written forwards and backwards. For example, 'racecar' is a palindrome, but 'fastcar' is not...
分类:其他好文   时间:2014-11-09 18:08:19    阅读次数:140
[LeetCode] Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Pana...
分类:其他好文   时间:2014-11-09 15:07:01    阅读次数:129
[LeetCode]Palindrome Partitioning 找出所有可能的回文组合
给定一个串,分割该串,使得每个子串都是回文串。找出所有可能的组合。 方法:暴搜+回溯 class Solution { public: int *b,n; vector >ans; void dfs(int id,string &s,int len){ if(id>=n){ if(len>0){ vectorvt; vt.push_back(s.substr(0...
分类:其他好文   时间:2014-11-09 11:18:19    阅读次数:174
LeetCode Valid Palindrome 有效回文(字符串)
1 class Solution { 2 public: 3 bool isPalindrome(string s) { 4 if(s=="") return true; 5 if(s.length()==1) return true; //单个字符,对称...
分类:其他好文   时间:2014-11-08 21:59:37    阅读次数:242
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!