Leetcode 009 - Palindrome Strings
5. Longest Palindromic Substring[M]
https://leetcode.com/problems/longest-palindromic-substring/
Description
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
Example 1:
1 | Input: "babad" |
Example 2:
1 | Input: "cbbd" |
Solution
https://leetcode.com/problems/longest-palindromic-substring/solution/
http://en.wikipedia.org/wiki/Longest_palindromic_substring
1 | class Solution: |
214. Shortest Palindrome[H]
https://leetcode.com/problems/shortest-palindrome/
Description
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:
1 | Input: "aacecaaa" |
Example 2:
1 | Input: "abcd" |
Solution
https://leetcode.com/problems/shortest-palindrome/solution/
https://leetcode.com/problems/shortest-palindrome/discuss/60250/My-recursive-Python-solution
1 | class Solution: |
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment





