<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:
        def manacher_odd(s):
            T = s
            n = len(T)
            P = [0] * n
            C = R = 0

            for i in range(1, n - 1):
                if (R > i):
                    P[i] = min(R - i, P[2 * C - i])

                while i + 1 + P[i]<n and  i - 1 - P[i]>=0 and T[i + 1 + P[i]] == T[i - 1 - P[i]]:
                    P[i] += 1

                if i + P[i] > R:
                    C, R = i, i + P[i]
            return P

        lps=manacher_odd(s)
        lps1=manacher_odd(s[::-1])

        left_best=[1]*len(s)
        right_best=[1]*len(s)
        
        ptr=0
        for i in range(len(s)):
            while ptr<i and i - ptr > lps[ptr]:ptr+=1
            left_best[i]=max(left_best[i-1], (i - ptr) * 2+1)


        ptr=0
        for i in range(len(s)-2,-1,-1):
            rel_i=len(s)-1-i
            while ptr<rel_i and rel_i - ptr > lps1[ptr]:ptr+=1
            right_best[i]=max(right_best[i+1], (rel_i - ptr) * 2+1)
        
        return max(left_best[i]*right_best[i+1] for i in range(len(s)-1))


817