🔥 Fastest way to solve this question || BEATS 100% 🔥
What question says\n Describe your first thoughts on how to solve this problem. \nThere is a function signFunc(x) that returns:\n\n1 if x is positive.\n-1 if x 
# What question says\n<!-- Describe your first thoughts on how to solve this problem. -->\nThere is a function signFunc(x) that returns:\n\n1 if x is positive.\n-1 if x is negative.\n0 if x is equal to 0.\n\nYou are given an integer array nums. Let product be the product of all values in the array nums.\n\n# Approach\n\n1. The arraySign method takes an integer array nums as input.\n\n2. The method initializes the product variable to 1, which represents a positive product.\n\n3. The loop iterates over each element num of the input array nums.\n\n4. If the current element num is equal to 0, then the method immediately returns 0, since the product of the array will also be 0.\n\n5. If the current element num is negative (num < 0), then the product variable is multiplied by -1, which effectively flips the sign of the product to negative.\n\n6. After the loop has finished iterating over all the elements, the method returns the value of product.\n\n7. If product is positive, the method returns 1, which represents a positive product.\n\n8. If product is negative, the method returns -1, which represents a negative product.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int arraySign(int[] nums) {\n        int sign = 1;\n        for (int num : nums) {\n            if (num == 0) {\n                return 0;\n            } else if (num < 0) {\n                sign *= -1;\n            }\n        }\n        return sign;\n    }\n}\n```
['Java']