题目:
Given a singly linked list, determine if it is a palindrome.
Follow up:
Could you do it in O(n) time and O(1) space?
题解:
判断一个链表是不是回文的,这里要求O(n)时间复杂度和O(1)的空间时间复杂度,总共想了三种办法,三种办法都用到了两个指针,符合...
分类:
编程语言 时间:
2015-07-29 12:13:09
阅读次数:
136
E. Palindrome QueryTime Limit: 20 SecMemory Limit: 256 MB题目连接http://codeforces.com/gym/100570/problem/EDescriptionDe Prezer loves palindrome strings. ...
分类:
其他好文 时间:
2015-07-29 00:28:50
阅读次数:
356
题目:
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" ...
分类:
编程语言 时间:
2015-07-28 16:05:25
阅读次数:
138
Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinki...
分类:
其他好文 时间:
2015-07-28 00:31:41
阅读次数:
124
Given a singly linked list, determine if it is a palindrome.
Follow up:
Could you do it in O(n) time and O(1) space?
给定一个单链表,判断它的元素是否是回文。要求在O(n)的时间复杂度和O(1)的空间复杂度内求解。如果没有时间复杂度的限制,可以直接将链表反转再比较就...
分类:
其他好文 时间:
2015-07-27 16:20:55
阅读次数:
88
给一个字符串,计算最少加多少个字符能够使字符串变成回文串(即从前往后读与从后往前读一样)。
有2种思路,一种是直接区间DP,dp[j][i]表示[i,j]这个子串要变成回文串需要添加多少个字符,状态转移方程
如下:
if(s[i]==s[j])
dp[j][i]=dp[j+1][i-1];
else
dp[j][i]=1+min(min[j+1][i],min[j][i-1])
第二种思路也比较容易想,要将一个字符串变为回文串,那么我们...
分类:
编程语言 时间:
2015-07-27 00:19:30
阅读次数:
239
Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?Hide Tags:Linked ListTwo Pointers 1 ...
分类:
其他好文 时间:
2015-07-26 22:26:57
阅读次数:
131
Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ofs...
分类:
其他好文 时间:
2015-07-26 15:25:58
阅读次数:
128
Given a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioning ofs.For example, giv...
分类:
其他好文 时间:
2015-07-26 15:24:54
阅读次数:
98
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...
分类:
其他好文 时间:
2015-07-26 12:38:25
阅读次数:
131