Palindrome Partitioning IV
Hard · String, Dynamic Programming
Given a string s, return true if it is possible to split the string s into three non-empty palindromic substrings. Otherwise, return false.
A string is said to be palindrome if it the same string when reversed.
Example 1
Input: s = "abcbdd" Output: true
"abcbdd" = "a" + "bcb" + "dd", and all three substrings are palindromes.
Example 2
Input: s = "bcbddxy" Output: false
s cannot be split into 3 palindromes.
Constraints
- 3 <= s.length <= 2000
- s consists only of lowercase English letters.
Starter code (python)
class Solution(object):
def checkPartitioning(self, s):
"""
:type s: str
:rtype: bool
"""
Related problems
- Longest Substring Without Repeating Characters (Medium)
- Longest Palindromic Substring (Medium)
- Roman to Integer (Easy)
Previous: Change Minimum Characters to Satisfy One of Three Conditions · Next: Can You Eat Your Favorite Candy on Your Favorite Day? · All problems
Zepruv is a technical interview practice platform. Read any problem for free; sign in to run your code, submit and keep your progress.