<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)
        if n == 2:
            return 1
        
        # Get lengths of palindromes at each character
        palindrome_lengths = self.manachers(s)
        
        # Array to store the maximum length of palindrome to the left of each index
        max_length_left = [0] * n
        max_length = 1
        max_length_left[0] = max_length
        
        for i in range(1, n):
            # Check if there is a palindrome ending at i with length greater than current max_length
            if palindrome_lengths[(i - max_length - 1 + i) // 2] > max_length:
                max_length += 2
            max_length_left[i] = max_length
        
        # Array to store the maximum length of palindrome to the right of each index
        max_length_right = [0] * n
        max_length = 1
        max_length_right[n - 1] = max_length
        
        for i in range(n - 2, -1, -1):
            # Check if there is a palindrome starting at i with length greater than current max_length
            if palindrome_lengths[(i + max_length + 1 + i) // 2] > max_length:
                max_length += 2
            max_length_right[i] = max_length
        
        # Calculate the maximum product of palindrome lengths on the left and right
        max_product = 1
        for i in range(1, n):
            max_product = max(max_product, max_length_left[i - 1] * max_length_right[i])
        
        return max_product
    
    def manachers(self, s: str) -> list[int]:
        length = len(s)
        palindrome_lengths = [0] * length
        center = 0  # Stores the center of the longest palindromic substring found so far
        right_boundary = 0  # Stores the right boundary of the longest palindromic substring found so far
        
        for i in range(length):
            # Get the mirror index of i
            mirror = 2 * center - i
            
            # If i is within the right boundary of the current longest palindrome
            # Use the minimum of the length of the palindrome at the mirror index or the distance to the right boundary
            if i < right_boundary:
                palindrome_lengths[i] = min(right_boundary - i, palindrome_lengths[mirror])
            
            # Expand the palindrome centered at i
            a = i + (1 + palindrome_lengths[i])
            b = i - (1 + palindrome_lengths[i])
            while a < length and b >= 0 and s[a] == s[b]:
                palindrome_lengths[i] += 1
                a += 1
                b -= 1
            
            # Update the center and right boundary if the expanded palindrome extends beyond the current right boundary
            if i + palindrome_lengths[i] > right_boundary:
                center = i
                right_boundary = i + palindrome_lengths[i]
        
        # Convert the radius to the length of the palindrome by adjusting to the format needed
        for i in range(length):
            palindrome_lengths[i] = 1 + 2 * palindrome_lengths[i]
        
        return palindrome_lengths
451