<p>Given an array of integers <code>nums</code>, find the maximum length of a subarray where the product of all its elements is positive.</p>

<p>A subarray of an array is a consecutive sequence of zero or more values taken out of that array.</p>

<p>Return <em>the maximum length of a subarray with positive product</em>.</p>

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

<pre>
<strong>Input:</strong> nums = [1,-2,-3,4]
<strong>Output:</strong> 4
<strong>Explanation:</strong> The array nums already has a positive product of 24.
</pre>

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

<pre>
<strong>Input:</strong> nums = [0,1,-2,-3,-4]
<strong>Output:</strong> 3
<strong>Explanation:</strong> The longest subarray with positive product is [1,-2,-3] which has a product of 6.
Notice that we cannot include 0 in the subarray since that&#39;ll make the product 0 which is not positive.</pre>

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

<pre>
<strong>Input:</strong> nums = [-1,-2,-3,0,1]
<strong>Output:</strong> 2
<strong>Explanation:</strong> The longest subarray with positive product is [-1,-2] or [-2,-3].
</pre>

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

<ul>
	<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
	<li><code>-10<sup>9</sup> &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
</ul>

class Solution {
public:
    int getMaxLen(vector<int>& nums){
        vector<vector<int>>x;
        vector<int>v;
          int count=0;
          pair<int,int>p={INT_MAX,INT_MIN};
          int j=-1;
        for(int i=0;i<(int)nums.size();i++){
                if(nums[i]==0){
                    v.push_back(count);
                    v.push_back(p.first);
                    v.push_back(p.second);
                    v.push_back(j+1);
                    v.push_back(i-1);
                     x.push_back(v);
                     count=0;
                     p={INT_MAX,INT_MIN};
                     j=i;
                     v.clear();
                }
                else{
                    if(nums[i]<0){
                        count++;
                        p.first=min(p.first,i);
                        p.second=max(p.second,i);
                    }
                }
        }
       v.push_back(count);
       v.push_back(p.first);
       v.push_back(p.second);
       v.push_back(j+1);
       v.push_back((int)nums.size()-1);
       x.push_back(v);
       v.clear();
    int maxe=0;
    for(int i=0;i<(int)x.size();i++){
         if((x[i][0]&1)==0){
            maxe=max(maxe,x[i][4]-x[i][3]+1);
         }
         else{
           maxe=max(maxe,max((x[i][4]-x[i][1]),(x[i][2]-x[i][3])));
         }
    }
    return maxe;
    }
};
64500