题目:传送门 题意:给你字符串 s ,问长度最大的字符串 t = a + b 是什么,其中,t 是回文串, a 是字符串 s 的前缀, b 是字符串 s 的后缀。 思路: 我们先把能构成回文的,前缀和后缀取出来,然后对剩下的字符串,求,最长的前缀回文,最长后缀回文,取两者最大即可。 #include ...
分类:
其他好文 时间:
2020-03-22 17:54:43
阅读次数:
64
如图,这次没有当作字符处理,和昨天的问题相似,改用运算解决。但是没有考虑溢出的情况: class Solution { public boolean isPalindrome(int x) { if (x<0){ return false; } if (x==0){ return true; } i ...
分类:
其他好文 时间:
2020-03-22 00:58:47
阅读次数:
99
"Link" 题意: $a$ 是 $s$ 的前缀,$b$ 是 $s$ 的后缀 使 $a+b$ 是可以找到的最大的回文串 $a$ 或 $b$ 可以是空串 思路: 找出最大长度 $k$ 使 $s[0,k 1]+s[len(s) k,len(s) 1]$ 是回文串 再用 Manacher 算法求出 $s[ ...
分类:
其他好文 时间:
2020-03-20 20:02:45
阅读次数:
88
题目大意 T组数据,每组给定一个字符串 s 求一个 最长的 字符串 t ,满足: 1. t 是一个 回文串 2. t = a+b , a是字符串s的前缀,b是字符串s的后缀 , 为拼接两字符串,ab可能为空串 数据范围 数据组数不超过 1e5 字符串的总共长度不超过 1e6 解题思路 (标准做 ...
分类:
其他好文 时间:
2020-03-20 09:21:17
阅读次数:
60
链接:https://leetcode-cn.com/problems/valid-palindrome/ 给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写。 说明:本题中,我们将空字符串定义为有效的回文串。 示例 1: 输入: "A man, a plan, a ca ...
分类:
其他好文 时间:
2020-03-20 00:50:33
阅读次数:
60
LeetCode 0409. Longest Palindrome最长回文串【Easy】【Python】【字符串】 Problem "LeetCode" Given a string which consists of lowercase or uppercase letters, find the ...
分类:
编程语言 时间:
2020-03-19 21:26:18
阅读次数:
69
由于给出的数可能超出 long long范围,所以不能对两数直接求和,必须模拟加法运算过程,不然最后一个测试点无法通过。 中文版。 1079 延迟的回文数 1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 5 bo ...
分类:
其他好文 时间:
2020-03-15 09:21:11
阅读次数:
53
You are given an array aa consisting of nn integers. Your task is to determine if aa has some subsequence of length at least 33 that is a palindrome. ...
分类:
其他好文 时间:
2020-03-14 23:35:49
阅读次数:
96
Q:给出一个字符串s,分割s使得分割出的每一个子串都是回文串 计算将字符串s分割成回文分割结果的最小切割数 例如:给定字符串s="aab", 返回1,因为回文分割结果["aa","b"]是切割一次生成的。 A: 动态规划问题。 cut[i] 表示子串(0,i)的最小回文切割,则最优解在cut[s.l ...
分类:
其他好文 时间:
2020-03-13 18:59:48
阅读次数:
57
https://www.imooc.com/article/details/id/35590 https://blog.csdn.net/cs_hnu_scw/article/details/79059965 https://blog.csdn.net/fly_fly_fly_pig/article ...
分类:
其他好文 时间:
2020-03-04 13:09:26
阅读次数:
75