Skip to content

Commit deb040b

Browse files
add 1979
1 parent ecd9c7b commit deb040b

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|1979|[Find Greatest Common Divisor of Array](https://leetcode.com/problems/find-greatest-common-divisor-of-array/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1979.java) ||Easy||
1112
|1974|[Minimum Time to Type Word Using Special Typewriter](https://leetcode.com/problems/minimum-time-to-type-word-using-special-typewriter/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1974.java) ||Easy||
1213
|1968|[Array With Elements Not Equal to Average of Neighbors](https://leetcode.com/problems/array-with-elements-not-equal-to-average-of-neighbors/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1968.java) ||Medium||
1314
|1967|[Number of Strings That Appear as Substrings in Word](https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1967.java) ||Easy||
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.fishercoder.solutions;
2+
3+
import java.util.Arrays;
4+
5+
public class _1979 {
6+
public static class Solution1 {
7+
public int findGCD(int[] nums) {
8+
Arrays.sort(nums);
9+
return getGcd(nums[0], nums[nums.length - 1]);
10+
}
11+
12+
int getGcd(int a, int b) {
13+
return b == 0 ? a : getGcd(b, a % b);
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)