Java | Two Pass | O(N) solution
The idea is whenever our product is positive, we try to update the max length. When we encounter a 0, we just reset our start index of subarray. \n\nWe do this 
The idea is whenever our product is positive, we try to update the max length. When we encounter a 0, we just reset our start index of subarray. \n\nWe do this twice. First one, from the begining of the array. Second is from the end of the array. \n\nConsider this: `nums = [-1,2,0,-2]`. For this we need to iterate again from the end of the array.\n\nTime complexity: O(N)\nSpace complexity: O(N)\n\n```\npublic int getMaxLen(int[] nums) {\n        int maxLength = 0;\n        int product = 1;\n        int prev = -1;\n        for(int i = 0; i < nums.length; i++){\n            int num = nums[i];\n            product = (product * num);\n\t\t\t// we don\'t wanna overflow \n            if(product != 0) product = product / Math.abs(product);\n            \n            if(product == 0) {\n                product = 1;\n                prev = i;\n            } else if(product > 0) {\n                maxLength = Math.max(maxLength, (i - prev));\n            }\n        }\n        \n        product = 1;\n        prev = nums.length;\n        for(int i = nums.length - 1; i >= 0; i--){\n            int num = nums[i];\n            product *= num;\n            if(product != 0) product = product / Math.abs(product);\n            \n            if(product == 0) {\n                product = 1;\n                prev = i;\n            } else if(product > 0){\n                maxLength = Math.max(maxLength, (prev - i));\n            }\n        }\n        \n        return maxLength;\n    }\n\t```
['Java']