Determinewhetheranintegerisapalindrome.Dothiswithoutextraspace.classSolution(object):
defnumLen(self,n):
i=1
whileTrue:
n/=10
ifn>0:
i+=1
else:
break
returni
defpow(self,n):
i=1
r=1
whilei<n:
r*=10
i+=1
returnr
defisPalindrome(self,x):
"""
:typex:i..
分类:
编程语言 时间:
2016-01-20 15:47:38
阅读次数:
176
234. Palindrome Linked List
My Submissions
Question
Total Accepted: 33856 Total
Submissions: 129644 Difficulty: Easy
Given a singly linked list, determine if it is a palindrome.
F...
分类:
其他好文 时间:
2016-01-17 13:37:25
阅读次数:
161
给定一个字符串,找出最多有多少个chunked palindrome,正常的palindrome是abccba, chunked palindrome的定义是:比如volvo, 可以把vo划分在一起,(vo) (l) (vo),那么它是个palindrome。求实现返回最大的chunk 数量。比如....
分类:
其他好文 时间:
2016-01-17 12:12:59
阅读次数:
145
Palindrome Linked List:Given a singly linked list, determine if it is a palindrome. 题意:判断给定的一个链表中数,是否为回文。 思路:参考http://www.bkjia.com/ASPjc/1031678.html...
分类:
其他好文 时间:
2016-01-14 20:36:40
阅读次数:
129
问题问的是最少可以把一个字符串分成几段,使每段都是回文串。一开始想直接区间DP,dp[i][j]表示子串[i,j]的答案,不过字符串长度1000,100W个状态,一个状态从多个状态转移来的,转移的时候要枚举,这样时间复杂度是不可行的。然后我就想降维度了,只能线性DP,dp[i]表示子串[0,i]的答...
分类:
其他好文 时间:
2016-01-14 18:56:30
阅读次数:
199
Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Subscribeto see which companies asked this questionSh...
分类:
其他好文 时间:
2016-01-03 22:16:41
阅读次数:
164
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...
分类:
其他好文 时间:
2016-01-03 20:54:02
阅读次数:
149
A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example,the name “anna” is a palindrome. Numbers can also be ...
分类:
其他好文 时间:
2015-12-27 16:05:44
阅读次数:
272
The number 151 is a prime palindrome because it is both a prime number and a palindrome (it is the same number when read forward as backward). Write a...
分类:
其他好文 时间:
2015-12-26 14:50:19
阅读次数:
198