Easy Solution || Java
Approach\n Describe your approach to solving the problem. \n- The input to the method arraySign is an array of integers called nums. The goal of the method is t
# Approach\n<!-- Describe your approach to solving the problem. -->\n- The input to the method arraySign is an array of integers called nums. The goal of the method is to return the sign of the product of all the elements in the array.\n\n- The method **signFunc** is called with **nums** as an argument. This method computes the sign of the product of all the elements in the array.\n\n- The variable **count** is initialized to 0. This variable will be used to count the number of negative elements in the array.\n\n- The loop **for(int i:nums)** iterates over all the elements in the array. For each element, if it is equal to 0, the method immediately returns 0 because the product of any number and 0 is 0.\n\n- If the element is negative (i.e., less than 0), the variable count is incremented by 1.\n\n- After the loop, the method checks whether the count of negative elements is even or odd. If it is even, the method returns 1 because the product of an even number of negative numbers is positive. If it is odd, the method returns -1 because the product of an odd number of negative numbers is negative.\n\n- Finally, the arraySign method returns the value returned by **signFunc**.\n\n# Complexity\n- Time complexity:\nThe time complexity of the provided arraySign method is O(n), where n is the length of the input array nums. This is because the method iterates over each element in the array exactly once.\n- Space complexity:\nThe space complexity of the method is O(1), because it only uses a constant amount of extra space to store the count variable. No additional data structures are used that depend on the size of the input array\n\n\n# Code\n```\nclass Solution {\n    public int arraySign(int[] nums) {\n        return signFunc(nums);\n    }\n    static int signFunc(int[] nums){\n        int count=0;\n        for(int i:nums)\n        {\n            if(i==0)\n                return 0;\n            if(i<0)\n            count++;\n        }\n        if(count%2==0)\n            return 1;\n        else \n            return -1;\n    }\n}\n```
['Array', 'Math', 'Java']