O(n^2)的方法,最后一个case超时。需要用kmp方法或者manacher方法才能O(n),先忽略了。 class Solution: def isPalindrome(self, sub: str) -> bool: for i in range(len(sub) // 2): if sub[ ...
分类:
其他好文 时间:
2020-02-07 18:29:59
阅读次数:
48
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121Output: true ...
分类:
其他好文 时间:
2020-02-06 20:03:07
阅读次数:
83
125. Valid Palindrome Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note : For the pur ...
分类:
其他好文 时间:
2020-02-05 23:49:36
阅读次数:
129
题目连接 题意:求一个字符串的最长回文子串 题解:是一个Manacher模板题,为了统一奇偶,先预处理在字符间添加间隔,使字符串长度变为偶数,例如"abc"添加分隔符后变成"$#a#b#c#",剩下的就很简单了,这个题也可以用哈希做。就时间复杂度来看Manacher明显比哈希快。 Manacher代 ...
分类:
其他好文 时间:
2020-02-04 23:46:00
阅读次数:
69
Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. Example 1: Input: "aba" Output: True Exa ...
分类:
其他好文 时间:
2020-02-04 11:04:16
阅读次数:
77
Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + ...
分类:
其他好文 时间:
2020-02-04 10:47:17
阅读次数:
71
A palindrome is a symmetrical string, that is, a string read identically from left to right as well as from right to left. You are to write a program ...
分类:
其他好文 时间:
2020-02-02 19:30:50
阅读次数:
72
Find the largest palindrome made from the product of two n-digit numbers. Since the result could be very large, you should return the largest palindro ...
分类:
编程语言 时间:
2020-02-01 10:47:36
阅读次数:
78
Given a palindromic string palindrome, replace exactly one character by any lowercase English letter so that the string becomes the lexicographically ...
分类:
其他好文 时间:
2020-01-30 09:47:14
阅读次数:
94
1、题目 9. Palindrome Number Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example ...
分类:
其他好文 时间:
2020-01-29 17:47:22
阅读次数:
55