11. Maximum Non-Overlapping Odd Palindrome Sum
β GFG solution to Maximum Non-Overlapping Odd Palindrome Sum problem: find maximum sum of lengths of two non-overlapping odd palindromes using Manacher's algorithm. π
π§© Problem Description
π Examples
Example 1
Input: s = "xyabacbcz"
Output: 6
Explanation: "aba" and "cbc" are non-overlapping odd-length palindromes.
Their lengths are 3 and 3 which gives the sum as 6.Example 2
Input: s = "gfgforgeeks"
Output: 4
Explanation: "gfg" and "g" are non-overlapping odd-length palindromes.
Their lengths are 3 and 1 which gives the sum as 4.π Constraints
β
My Approach
Manacher's Algorithm + Dynamic Programming
Key Insights:
π Time and Auxiliary Space Complexity
π§βπ» Code (C++)
β Code (Java)
π Code (Python)
π§ Contribution and Support
πVisitor Count
Last updated