<p>You are given a <strong>0-indexed</strong> string <code>s</code> and are tasked with finding two <strong>non-intersecting palindromic </strong>substrings of <strong>odd</strong> length such that the product of their lengths is maximized.</p>

<p>More formally, you want to choose four integers <code>i</code>, <code>j</code>, <code>k</code>, <code>l</code> such that <code>0 &lt;= i &lt;= j &lt; k &lt;= l &lt; s.length</code> and both the substrings <code>s[i...j]</code> and <code>s[k...l]</code> are palindromes and have odd lengths. <code>s[i...j]</code> denotes a substring from index <code>i</code> to index <code>j</code> <strong>inclusive</strong>.</p>

<p>Return <em>the <strong>maximum</strong> possible product of the lengths of the two non-intersecting palindromic substrings.</em></p>

<p>A <strong>palindrome</strong> is a string that is the same forward and backward. A <strong>substring</strong> is a contiguous sequence of characters in a string.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;ababbb&quot;
<strong>Output:</strong> 9
<strong>Explanation:</strong> Substrings &quot;aba&quot; and &quot;bbb&quot; are palindromes with odd length. product = 3 * 3 = 9.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;zaaaxbbby&quot;
<strong>Output:</strong> 9
<strong>Explanation:</strong> Substrings &quot;aaa&quot; and &quot;bbb&quot; are palindromes with odd length. product = 3 * 3 = 9.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>2 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
	<li><code>s</code> consists of lowercase English letters.</li>
</ul>

class Solution:
    def maxProduct(self, s: str) -> int:
        n = len(s)
        
        # Step 1: Use Manacher's algorithm to find the longest palindromic substring centered at each position.
        hlen = [0] * n  # hlen[i] will store the half-length of the longest odd-length palindrome centered at i.
        center = right = 0
        
        for i in range(n):
            if i < right:
                hlen[i] = min(right - i, hlen[2 * center - i])
            # Expand around center i
            while 0 <= i - 1 - hlen[i] and i + 1 + hlen[i] < n and s[i - 1 - hlen[i]] == s[i + 1 + hlen[i]]:
                hlen[i] += 1
            # Update the center and right boundary if the palindrome extends beyond the current right boundary
            if right < i + hlen[i]:
                center, right = i, i + hlen[i]
        
        # Step 2: Calculate the maximum odd-length palindrome ending at or before each position (prefix) and starting at or after each position (suffix).
        prefix = [0] * n
        suffix = [0] * n
        
        for i in range(n):
            # Update prefix and suffix arrays with the maximum palindrome length at each position
            prefix[i + hlen[i]] = max(prefix[i + hlen[i]], 2 * hlen[i] + 1)
            suffix[i - hlen[i]] = max(suffix[i - hlen[i]], 2 * hlen[i] + 1)
        
        # Step 3: Propagate the maximum palindrome lengths to ensure prefix[i] is the maximum palindrome length ending at or before i,
        # and suffix[i] is the maximum palindrome length starting at or after i.
        for i in range(1, n):
            prefix[~i] = max(prefix[~i], prefix[~i + 1] - 2)
            suffix[i] = max(suffix[i], suffix[i - 1] - 2)
        
        for i in range(1, n):
            prefix[i] = max(prefix[i - 1], prefix[i])
            suffix[~i] = max(suffix[~i], suffix[~i + 1])
        
        # Step 4: Calculate the maximum product of lengths of two non-intersecting palindromic substrings.
        max_product = 0
        for i in range(1, n):
            max_product = max(max_product, prefix[i - 1] * suffix[i])
        
        return max_product
959