1979. Find Greatest Common Divisor of Array
Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 79% Topics: Array, Math, Number Theory
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(n)
# Space: O(1)
import fractions
class Solution(object):
def findGCD(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
return fractions.gcd(min(nums), max(nums))
Solution from kamyu104/LeetCode-Solutions · MIT