Find Greatest Common Divisor of Array LeetCode solution in Python

1
# Runtime: 282 ms (Top 5.10%) | Memory: 13.9 MB (Top 81.34%)
2
class Solution:
3
def findGCD(self, nums: List[int]) -> int:
4
i_min = min(nums)
5
i_max = max(nums)
6
greater = i_max
7
while True:
8
if greater % i_min == 0 and greater % i_max == 0:
9
lcm = greater
10
break
11
greater += 1
12
return int(i_min / (lcm / i_max))

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0