由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - how to resolve this question?
相关主题
on-site的时候Trie和suffix tree会考coding吗?MS SDET面经
问道算法题问两个Palindrome的老题
leetcode上的Longest Palindromic Substring难道不收brute forpalindrome question
leetcode里的Palindrome partition问题请教道算法题
python搞不定Longest Palindromic Substring啊问道老题
请问一道Leetcode的题:Longest Palindromic Substring弱问如何用suffix tree求最长palindrome
攒rp整理面试题(1)string match/text searchleetcode online judge Longest Palindromic Substring memory limit exceeded
Amazon Summer Intern Offer, 发面经像Longest Palindromic Substring这种题,面试的时候
相关话题的讨论汇总
话题: resolve话题: question话题: string话题: my
进入JobHunting版参与讨论
1 (共1页)
r*****t
发帖数: 68
1
Q: Find the number of substrings of a string that are palindromes.
Can it be solved by O(n)?
My idea is to build an array p[i,j]=1 if string(i,...j) is palindrome
otherwise p[i,j]=0. Then sum of p[i,j] is the total number. This is a DP
idea by O(n^2).
Better solution? Thanks.
f*****e
发帖数: 2992
2
看起来stack可能有用。

【在 r*****t 的大作中提到】
: Q: Find the number of substrings of a string that are palindromes.
: Can it be solved by O(n)?
: My idea is to build an array p[i,j]=1 if string(i,...j) is palindrome
: otherwise p[i,j]=0. Then sum of p[i,j] is the total number. This is a DP
: idea by O(n^2).
: Better solution? Thanks.

r*****e
发帖数: 792
3
my first instinct is to use Manacher's Algorithm which finds the longest
palindrome in linear time. But not sure if it can be applied to solve
this problem where multiple palindromes need to be found.

【在 r*****t 的大作中提到】
: Q: Find the number of substrings of a string that are palindromes.
: Can it be solved by O(n)?
: My idea is to build an array p[i,j]=1 if string(i,...j) is palindrome
: otherwise p[i,j]=0. Then sum of p[i,j] is the total number. This is a DP
: idea by O(n^2).
: Better solution? Thanks.

1 (共1页)
进入JobHunting版参与讨论
相关主题
像Longest Palindromic Substring这种题,面试的时候python搞不定Longest Palindromic Substring啊
Memory Limit Exceeded: Longest Palindromic Substring请问一道Leetcode的题:Longest Palindromic Substring
刚刚结束的Yelp电面面经,顺求bless攒rp整理面试题(1)string match/text search
leetcode Longest Palindromic Substring Part II 有问题?Amazon Summer Intern Offer, 发面经
on-site的时候Trie和suffix tree会考coding吗?MS SDET面经
问道算法题问两个Palindrome的老题
leetcode上的Longest Palindromic Substring难道不收brute forpalindrome question
leetcode里的Palindrome partition问题请教道算法题
相关话题的讨论汇总
话题: resolve话题: question话题: string话题: my