话说博主在写Max Chunks To Make Sorted II这篇帖子的解法四时,写到使用单调栈Monotone Stack的解法时,突然脑中触电一般,想起了之前曾经在此贴LeetCode All in One 题目讲解汇总(持续更新中...)的留言区中说要写单调栈的总结帖,当时答应了要写,就去LeetCode上看标记为Stack的题,可是发现有好多题,而且很多用的不是单调栈,于是博主一个一个的看了起来,但是无奈太多了,一直没有时间全部看完,就一直没有动笔写.虽说时间就像那啥,挤挤总会有的…
Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase English letters only and its length will not exceed 100…
Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation. For example: Given "aacecaaa", return "aaacecaaa&qu…
Given a string s, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation. Example 1: Input: "aacecaaa" Output: "aaacecaaa&quo…
复杂度: O(len(a)+len(b)) 技巧及注意: 在匹配的时候记住先要自身匹配然后再匹配即可,同时边界问题不能忽略,处理好点吧. #include <cstdio> #include <cstring> using namespace std; const int N=10000; char a[N], b[N]; int p[N]; int main() { scanf("%s%s", a+1, b+1); int i, j, siza=strlen(…