easy 3 line solution //C++ code //BEATS 100% 
ApproachLet's walk through a dry run of the provided code with the input nums = [12, 5, 7, 23].Initialization:cpp
auto gcd = nums[0];  // gcd = 12
First iterati
# Approach 
    
Let's walk through a dry run of the provided code with the input nums = [12, 5, 7, 23].

Initialization:

cpp
auto gcd = nums[0];  // gcd = 12
First iteration:

n = 12

Update gcd:

cpp
gcd = __gcd(12, 12);  // gcd = 12
Second iteration:

n = 5

Update gcd:

cpp
gcd = __gcd(12, 5);  // gcd = 1
Third iteration:

n = 7

Update gcd:

cpp
gcd = __gcd(1, 7);  // gcd = 1
Fourth iteration:

n = 23

Update gcd:

cpp
gcd = __gcd(1, 23);  // gcd = 1
After iterating through all the elements in the nums array, the final value of gcd is 1.

Return value:

cpp
return gcd == 1;  // return true
So, the function will return true for the input nums = [12, 5, 7, 23] 
# Complexity
- Time complexity: O(N)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:O(N)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
    public:
    bool isGoodArray(vector<int>& nums) {
    auto gcd = nums[0];
    for (auto n : nums) gcd = __gcd(gcd, n);
    return gcd == 1;
  }
};
```
['Array', 'Math', 'Number Theory', 'C++']