Mirror Cut Catalog
Preview mode. Log in to edit, run, submit, and save progress.
Hard
Mirror Cut Catalog
A secure memo can be split into one or more contiguous tokens. A split is valid only if every token in the split is a palindrome. The entire memo must be covered by the tokens in order, with no missing or overlapping characters. Count how many different valid splits exist. Because the count can be large, return it modulo 1000000007. Input Format: You are given a string s. Output Format: Return the number of palindromic partition plans modulo 1000000007.
Examples
Example 1
Input:
s = "aab"
Output:
2
Explanation: Valid mirror cuts are ["a|a|b", "aa|b"]. There are 2, so the output is 2.
Approach hint
Precompute palindromic intervals.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.
solution.cpp