java easy and fast solution 2ms
\nclass Solution {\n    public int getMaxLen(int[] nums) {\n        int posLen = 0; // positive length\n        int negLen = 0; // negetive length\n        int 
```\nclass Solution {\n    public int getMaxLen(int[] nums) {\n        int posLen = 0; // positive length\n        int negLen = 0; // negetive length\n        int res = 0;\n        for (int num : nums) {\n            if (num == 0) {\n                posLen = 0;\n                negLen = 0;\n            } else if (num > 0) {\n                posLen++;\n                negLen = negLen == 0 ? 0 : negLen+1;\n            } else {\n                int temp = posLen;\n                posLen = negLen == 0 ? 0 : negLen + 1;\n                negLen = temp + 1;\n            }\n            res = Math.max(res, posLen);\n        }\n        return res;\n    }\n}\n```
['Java']