<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:
        palins = [0]*len(s)
        l = 0
        r = 0
        a = [0]*len(s)
        b = [0]*len(s)
        for i in range(len(s)):
            palins[i] = max(1,min(r-i,palins[r+l-i]))
            a[i+palins[i]-1] = max(a[i+palins[i]-1],2*palins[i]-1)
            b[i-palins[i]+1] = max(b[i-palins[i]+1],2*palins[i]-1)
            while i+palins[i]<len(s) and i-palins[i]>=0 and s[i+palins[i]] == s[i-palins[i]]:
                a[i+palins[i]] = max(a[i+palins[i]],2*palins[i]+1)
                b[i-palins[i]] = max(b[i-palins[i]],2*palins[i]+1)
                palins[i]+=1
            if i+palins[i]>r:
                r = i+palins[i]
                l = i-palins[i]
        '''a = [0]*len(s)
        b = [0]*len(s)
        for i,p in enumerate(palins):
            a[i+p-1] = max(a[i+p-1],2*p-1)
            b[i-p+1] = max(b[i-p+1],2*p-1)'''
        print(a)
        print(b)
        for i in range(1,len(s)):
            a[i] = max(a[i],a[i-1])
            b[~i] = max(b[~i],b[-i])
        ans = 0
        for i in range(1,len(s)):
            ans = max(a[i-1]*b[i],ans)
        return ans
        '''for i in range(len(s)):
            if i<r:
                flip = (l+r-1)-i
                if (palins[flip]-1)//2<flip-l:
                    palins[i] = palins[flip]
                    continue
                else:
                    j = flip-l
            else:
                j = 0
            while i+j+1<len(s) and i-j-1>=0 and s[i+j+1] == s[i-j-1]:
                j+=1
            palins[i] = 2*j+1
            l = i-j
            r = i+j+1'''
        #return 0
                

1022