判断一个整数是否是回文数 注意点: 负数不是,因为多了一个负号 小心溢出,比较的时候不要将数字12345EDCBA变成ABCDE54321进行比较,而是将ABCDE5432和12345EDCB进行比较。 class Solution {public: bool isPalindrome(int x)...
分类:
其他好文 时间:
2015-03-08 11:34:19
阅读次数:
129
题意: 输入一个串,输出里面最长的回文子串。
做法:后缀数组 比如 输入abc 。 那构造串 abc#cba。 然后用后缀数组模版。 初始化RMQ后,枚举任意一个在#前面的点,奇回文和偶回文都各自考虑下,
用lcp,找出后缀i,j的最长公共前缀。得到的最大的就是最长回文子串了。...
分类:
编程语言 时间:
2015-03-07 21:24:05
阅读次数:
276
URAL 1297. Palindrome(后缀数组 求最长回文子串)...
分类:
编程语言 时间:
2015-03-07 20:04:10
阅读次数:
157
Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers.
Some hints: Could negative integers be palindromes?...
分类:
其他好文 时间:
2015-03-06 14:14:56
阅读次数:
111
判断字符串是否是回文:1、输入:hello world dlrow olleh输出:12、输入:nihao hello输出:0代码#include #include int palindrome(char * p){ if(NULL == p) { return 0; ...
分类:
编程语言 时间:
2015-03-05 14:29:03
阅读次数:
149
最长回文子串动态规划的方法的参考Palindrome Partitioning (回文子串题)代码:class Solution {public: string longestPalindrome(string s) { int n=s.size(); int dp...
分类:
其他好文 时间:
2015-03-03 20:39:26
阅读次数:
105
Given a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioning ofs.For example, giv...
分类:
其他好文 时间:
2015-03-03 18:34:37
阅读次数:
132
代码:class Solution {public: bool isValid(string s) { string left = "([{"; string right = ")]}"; stack stk; for(auto c : ...
分类:
其他好文 时间:
2015-03-03 01:04:29
阅读次数:
185
题目Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = “aab”,
Return 1 sinc...
分类:
其他好文 时间:
2015-03-02 23:58:14
阅读次数:
368
代码: 1 class Solution { 2 public: 3 bool isPalindrome(string s) { 4 transform(s.begin(), s.end(), s.begin(), ::tolower); 5 auto lef...
分类:
其他好文 时间:
2015-03-02 23:51:02
阅读次数:
170