✅ Short & Simple Solution | Maintain sign of Product of Number
Just simply iterate through the array and maintain the sign of the product of all numbers.\n\nAtlast, we will have the following cases -\n\n1. If we had atleast
Just simply iterate through the array and maintain the sign of the product of all numbers.\n\nAtlast, we will have the following cases -\n\n1. If we had atleast one zero in the array, **return 0**. \n2. If the final sign is 1 (denoting positive), **return 1**.\n3. Otherwise, the final sign is -1, so **return -1**\n\n```\nint arraySign(vector<int>& nums) {\n\tint sign = 1;\n\tfor(auto& num : nums) \n\t\tif(!num) return 0;\n\t\telse sign *= (num > 0 ? 1 : -1);\n\treturn sign;\n}\n```\n\n***Time Complexity :*** **`O(N)`**\n***Space Complexity :*** **`O(1)`**\n\n---\n---\n
['C']