<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)
        l,r = 0,-1
        d = [0 for i in range(n)]
        for i,a in enumerate(s):
            k = 1 if i > r else min(d[l+r-i],r-i+1)
            while k<=i and k<n-i and s[i-k] == s[i+k]:
                k += 1
            d[i] = k
            k -= 1
            if i + k > r:
                l = i-k
                r = i+k
        rmost = [i+d[i]-1 for i in range(n)]
        lmost = [i-d[i]+1 for i in range(n)]
        heapleft = []
        heapright = []
        pre = []
        suf = []
        currp = 1
        for i in range(n):
            while heapleft and heapleft[0][0]+heapleft[0][1]<=i:
                currp = max(currp,heapleft[0][1])
                heapq.heappop(heapleft)
            if heapleft:
                currp = max(currp,i-heapleft[0][0]+1)
            pre.append(currp*2 - 1)
            heapq.heappush(heapleft,(i,d[i]))
        currp = 1
        for i in range(n-1,-1,-1):
            while heapright and -heapright[0][0]-heapright[0][1]>=i:
                currp = max(currp,heapright[0][1])
                heapq.heappop(heapright)
            if heapright:
                currp = max(currp,-heapright[0][0]-i+1)
            suf.append(currp*2 - 1)
            heapq.heappush(heapright,(-i,d[i]))
        suf = suf[::-1]
        return max([pre[i]*suf[i+1] for i in range(n-1)])





        
939