Ball Blasting Game Morteza is playing a ball blasting game. In this game there is a chain of different colored balls. He is expected to explode as many balls as possible by aligning same-colored balls and making a sequence of them. To align balls, he…
推荐两个讲得很好的博客: http://blog.sina.com.cn/s/blog_70811e1a01014esn.html https://segmentfault.com/a/1190000003914228 #include<cstring> #include<cstdio> #include<algorithm> #define N (22000010) using namespace std; int n, ans, mid, mx; int p[N];…
给定一个字符串求出其中最长个公共回文串. 举列子: abab -->回文串长度为2 以前的算法诸如: 扩展kmp求法过于麻烦,看到有一篇博文(http://leetcode.com/2011/11/longest-palindromic-substring-part-ii.html),写了一个关于这样的算法,按耐不住自己内心的小激动,就去学了下,于是将自己学习的一点点的理解记录下来: 它的处理方法是: 对于这样一个字符串: abab: a b a b 我们对于每一个字符串的进行逐个…
题目链接:Longest Palindromic Substring 1. 问题描述 Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 2. 各种解法复杂度 暴力枚举:O(N^2) 记忆化搜索:O(N…