✅Java 100% Faster🔥||Full Explaination🔥||Comments||lBeginner Friendly🔥
Intuition\n Describe your first thoughts on how to solve this problem. \nWe need to only predict the sign of the product of all the element in the array.\n1. If
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe need to only predict the sign of the product of all the element in the array.\n1. If we found 0 return 0 because anything one multipled to 0 will be 0 only.\n2. Initalize a counter and count the total negative element present in the array.\n3. If negative count is mutliple of 2 then the product output will be positive number so retrun 1.\n4. If negative count is not a mutliple of 2 then the product output will be negative number so retrun 0.\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 countMinus = 0;\n        for(int i = 0 ; i < nums.length ; i ++){\n            if(nums[i] == 0){\n                return 0; // return 0 if we found a 0 in the array\n            }\n            if(nums[i] < 0){\n                countMinus++; //increment the count wehn we found a negative number\n            }\n        }\n        //check if countMinus is multiple of 2 then return 1 else return -1\n        return countMinus % 2 == 0 ? 1 : -1;\n    }\n}\n```\n**Please UpVote If you like it Happy Coding :)\nIf you really found my solution helpful please upvote it, as it motivates me to post such kind of codes and help the coding community, if you have some queries or some improvements please feel free to comment and share your views.**
['Array', 'Math', 'Java']