💥💥TypeScript | 100% beats runtime and memory [EXPLAINED]
\n\n# Intuition\nTo solve the problem, I realized that if I can find a common factor among all numbers in the array, it tells me something about whether I can m
\n\n# Intuition\nTo solve the problem, I realized that if I can find a common factor among all numbers in the array, it tells me something about whether I can make the number 1 from these numbers. If the greatest common divisor (GCD) of the entire array is 1, then it means I can indeed form the number 1 using some combination of these numbers and their multipliers.\n\n\n# Approach\nCalculate the GCD: Start with the first number and iteratively find the GCD of it with each subsequent number in the array.\n\n\nCheck the Result: If the GCD ever becomes 1, I know it\'s possible to form the number 1, so I return true. If the loop finishes and the GCD is still greater than 1, return false.\n\n\n# Complexity\n- Time complexity:\nO(n * log(max)) where n is the number of elements in the array and max is the maximum number in the array. This is because computing the GCD takes O(log(max)) time, and I do this for each element.\n\n- Space complexity:\nO(1). I only need a few extra variables to store the GCD and perform calculations, so the space used doesn\u2019t depend on the size of the input.\n\n# Code\n```typescript []\nfunction isGoodArray(nums: number[]): boolean {\n    const gcd = (a: number, b: number): number => {\n        while (b !== 0) {\n            const temp = b;\n            b = a % b;\n            a = temp;\n        }\n        return a;\n    };\n\n    let currentGCD = nums[0];\n    for (let i = 1; i < nums.length; i++) {\n        currentGCD = gcd(currentGCD, nums[i]);\n        if (currentGCD === 1) {\n            return true;\n        }\n    }\n    return currentGCD === 1;\n}\n\n```
['TypeScript']