Best O(N) Solution
Approach\nOptimal Approach\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\npublic:\n    int arraySign(vect
# Approach\nOptimal Approach\n\n# Complexity\n- Time complexity:\n$$O(n)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```\nclass Solution {\npublic:\n    int arraySign(vector<int>& nums) {\n        int negCnt = 0;\n        for (int i = 0; i < nums.size(); i++) {\n            if (nums[i] == 0)\n                return 0;\n            if (nums[i] < 0)\n                negCnt++;    \n        }\n        return (negCnt % 2 == 0) ? 1 : -1;\n    }\n};\n```
['C++']