码迷,mamicode.com
首页 >  
搜索关键字:palindrome    ( 1561个结果
寻找回文数的python的实现
寻找回文数寻找回文数也是一个比较好玩的题目,也是学习python的一个简单的filter()函数的应用解决方法:即按照回文数的特点进行即可。方法一:一行代码解决#coding=UTF-8 #寻找回文数 def is_palindrome(n): s=str(n) return s[0:len(s)//2]==s[-1:len(s)//2:-1]...
分类:编程语言   时间:2015-07-09 22:44:12    阅读次数:288
UVa 11475 - Extend to Palindrome
題目:給你一個字符串,在後面拼接一部分使得它變成回文串,使得串最短,輸出這個回文串。 分析:KMP,dp。這裡利用KMP算法將串和它的轉置匹配,看結束時匹配的長度即可。             因為串比較長,使用KMP比較合適,KMP原理請參照AC自動機總結。 說明:╮(╯▽╰)╭。 #include #include #include char strA[100001]; cha...
分类:其他好文   时间:2015-07-09 17:59:34    阅读次数:246
Codeforces 311(div 2):E. Ann and Half-Palindrome
题目描述:           给定半回文子串的定义,现给你一个串S和一个整数K,输出S所有子串中且是半回文排名第K的子串,半回文子串按照字典序升序顺序。(len(S) 分析:              首先,定义dp[i][j]表示S[i....j]是否为半回文子串,可以在的时间内求出所有的状态。现在,需要计算排名第K的半回文子串,我们可以通过将所有的半回文子串插入到一颗字典树中...
分类:其他好文   时间:2015-07-08 14:41:07    阅读次数:138
Valid Palindrome
回文,先提取有效字符,之后进行前后项匹配 1 class Solution { 2 public: 3 bool isPalindrome(string s) { 4 vector change; 5 int size=s.length(); 6 ...
分类:其他好文   时间:2015-07-08 00:15:54    阅读次数:168
[LeetCode][Java] Palindrome Number
题目: Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of converting the integer to...
分类:编程语言   时间:2015-07-07 19:34:48    阅读次数:129
LeetCode131:Palindrome Partitioning
Given 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 [...
分类:其他好文   时间:2015-07-07 19:28:43    阅读次数:116
Reverse Integer - Palindrome Number - 简单模拟
第一个题目是将整数进行反转,这个题实现反转并不难,主要关键点在于如何进行溢出判断。溢出判断再上一篇字符串转整数中已有介绍,本题采用其中的第三种方法,将数字转为字符串,使用字符串比较大小的方法进行比较。代码如下: 1 class Solution { 2 public: 3 int rever...
分类:其他好文   时间:2015-07-07 14:24:19    阅读次数:100
Leetcode:Palindrome Number
题目出处:https://leetcode.com/problems/palindrome-number/ 题目:Determine whether an integer is a palindrome. Do this without extra space. 翻译:判断一个整型数是否是回文数 思路:将整型数转化为字符串,依次比较首尾 代码: public class Solution...
分类:其他好文   时间:2015-07-04 14:08:01    阅读次数:171
[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: Panama” is a palindrome. “race a car” is not a palin...
分类:其他好文   时间:2015-07-02 22:38:27    阅读次数:132
Codeforces Round #311 (Div. 2) E. Ann and Half-Palindrome (DP+字典树)
题目地址:传送门 先用dp求出所有的符合要求的半回文串,标记出来。然后构造字典树。然后再dfs一遍求出所有节点的子树和,最后搜一遍就能找出第k个来了。 代码如下:#include #include #include #include #include #include #i...
分类:其他好文   时间:2015-07-02 22:35:29    阅读次数:207
1561条   上一页 1 ... 96 97 98 99 100 ... 157 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!