beats 100%
# Intuition\nWent through the hints and figured out an approach.First thought need **to use subarrays but then realized that the solution using the GCD of the entire array is still valid because the concept of a linear combination of numbers works for any subset of the array. If the GCD of all the elements in the array is 1, then it\'s possible to form 1 from some subset of those numbers, regardless of whether the elements are contiguous or not.**\n\n# Approach\nax+by=1;\ngcd(a,b)=1\n\n# Complexity\n- Time complexity:O(nlogM)\nn is the number of elements in the array nums.\nM is the maximum value in the array nums.\n- Space complexity:\nO(1)\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int gcd(int a,int b){\n        if (b>a){\n            return gcd(b,a);\n        \n        }\n        if (b==0) return a;\n        return gcd(b,a%b);\n        \n    }\n    bool isGoodArray(vector<int>& nums) {\n        int gcd_=nums[0];\n        for (int i=1;i<=nums.size()-1;i++){\n            gcd_=gcd(gcd_,nums[i]);\n            if (gcd_==1){\n                return true;\n            }\n        }\n        return gcd_==1;\n    }\n};\n```
['C++']