2025-08-16 10:22:50 +0000 UTC
Find Greatest Common Divisor of Array
Categories:
Links
Code
class Solution:
def findGCD(self, nums: List[int]) -> int:
nums.sort()
small, big = nums[0], nums[-1]
for i in range(1, small + 1):
if small % i != 0:
continue
val = small // i
if big % val == 0:
return val
raise Exception