Solution in Java | 100% Faster
hint - Finding gcd of numbers in the given array, if (gcd==1) then return true.(i.e. it is a good array); else return false.\n\nclass Solution {\n    public int
hint - Finding gcd of numbers in the given array, if (gcd==1) then return true.(i.e. it is a good array); else return false.\n```\nclass Solution {\n    public int gcd(int a, int b){\n        if(a==0)\n            return b;\n        return gcd(b%a,a);\n    }\n    public boolean isGoodArray(int[] nums) {\n        if(nums.length==1){\n            if(nums[0]!=1)\n                return false;\n            else\n                return true;\n        }\n        int res=gcd(nums[0],nums[1]);\n        for(int i=2;i<nums.length;i++){\n            res=gcd(res,nums[i]);\n        }\n        return (res==1)?true:false;\n    }\n}\n```\nPlease **upvote**, if you like the solution:)
[]