EASY soultion with DRY RUN - JAVA
Intuition\nAt every iteration, tracking maximum length of positive multiplicative result and negative multiplicative result can help.\nMultiplicative Result : r
**Intuition**\nAt every iteration, tracking maximum length of positive multiplicative result and negative multiplicative result can help.\nMultiplicative Result : result(+ve/-ve) of multiplication of bunch of numbers(some of which can be +ve/-ve)\n\n**Algorithm**\n1. If we see a 0, we gotta start off things again\n2. If we see a positive number :\n\t\t2.1. Increase length of positive mutilpicative result till now.\n\t\t2.2. Increase length of negative  mutilpicative result till now, unless we had not encountered any negative before.\n3. If we see a negative number:\n\t\t3.1. It\'s time to swap positive and negative multiplicative results\' lengths and do similar task as we did in above case.\n4. In each iteration, use the length of positive mutilpicative result to compute answer. \n\n**Dry Run**\n```\nelements      :   9    5    8    2    -6    4    -3    0    2    -5    15    10    -7    9    -2\npositive_len  :   1    2    3    4     0    1     7    0    1     0     1     2     5    6     5\nnegative_len  :   0    0    0    0     5    6     2    0    0     2     3     4     3    4     7\n\n```\nAnswer : Max(all these positive_len values) => 7\n```\nclass Solution {\n    public int getMaxLen(int[] nums) {\n        int positive = 0, negative = 0;    // length of positive and negative results\n        int ans = 0;\n        for(int x : nums) {\n            if(x == 0)  {\n                positive = 0;\n                negative = 0;\n            }\n            else if(x > 0) {\n                positive++;\n                negative = negative == 0 ? 0  : negative+1;\n            }\n            else {\n                int temp = positive;\n                positive = negative == 0 ? 0  : negative+1;\n                negative = temp+1;\n            }\n            ans = Math.max(ans, positive);\n        }\n        return ans;\n    }\n}\n```
['Java']