Problem statement

https://binarysearch.com/problems/Greatest-Common-Divisor/

Solution

Just do what is asked, we can use reduce and function gcd from math library.

Complexity

It is O(n log M) for time and O(1) for space.

Code

class Solution:
    def solve(self, nums):
        return reduce(gcd, nums, 0)