[java]Easy understanding two pointers O(n)
\nclass Solution {\n    public int getMaxLen(int[] nums) {\n        int res = 0, n = nums.length;\n        int pos = n, neg = n;\n        int i = 0;\n        wh
```\nclass Solution {\n    public int getMaxLen(int[] nums) {\n        int res = 0, n = nums.length;\n        int pos = n, neg = n;\n        int i = 0;\n        while (i < n) {\n            int j = i, count = 0;\n            while (j < n && nums[j] != 0) {\n                if (nums[j++] < 0) count++;\n                if (count % 2 == 0) res = Math.max(res, j - i);\n            }\n            while (i < j) {\n                if (nums[i++] < 0) count--;\n                if (count % 2 == 0) res = Math.max(res, j - i);\n            }\n            i++;\n        }\n        return res;\n    }\n}\n```
[]