File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 1
- # 1,666 LeetCode solutions in JavaScript
1
+ # 1,667 LeetCode solutions in JavaScript
2
2
3
3
[ https://leetcodejavascript.com ] ( https://leetcodejavascript.com )
4
4
1518
1518
1975|[ Maximum Matrix Sum] ( ./solutions/1975-maximum-matrix-sum.js ) |Medium|
1519
1519
1976|[ Number of Ways to Arrive at Destination] ( ./solutions/1976-number-of-ways-to-arrive-at-destination.js ) |Medium|
1520
1520
1977|[ Number of Ways to Separate Numbers] ( ./solutions/1977-number-of-ways-to-separate-numbers.js ) |Hard|
1521
+ 1979|[ Find Greatest Common Divisor of Array] ( ./solutions/1979-find-greatest-common-divisor-of-array.js ) |Easy|
1521
1522
1980|[ Find Unique Binary String] ( ./solutions/1980-find-unique-binary-string.js ) |Medium|
1522
1523
1985|[ Find the Kth Largest Integer in the Array] ( ./solutions/1985-find-the-kth-largest-integer-in-the-array.js ) |Medium|
1523
1524
1996|[ The Number of Weak Characters in the Game] ( ./solutions/1996-the-number-of-weak-characters-in-the-game.js ) |Medium|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 1979. Find Greatest Common Divisor of Array
3
+ * https://leetcode.com/problems/find-greatest-common-divisor-of-array/
4
+ * Difficulty: Easy
5
+ *
6
+ * Given an integer array nums, return the greatest common divisor of the smallest number and
7
+ * largest number in nums.
8
+ *
9
+ * The greatest common divisor of two numbers is the largest positive integer that evenly
10
+ * divides both numbers.
11
+ */
12
+
13
+ /**
14
+ * @param {number[] } nums
15
+ * @return {number }
16
+ */
17
+ var findGCD = function ( nums ) {
18
+ return gcd ( Math . min ( ...nums ) , Math . max ( ...nums ) ) ;
19
+
20
+ function gcd ( a , b ) {
21
+ return b === 0 ? a : gcd ( b , a % b ) ;
22
+ }
23
+ } ;
You can’t perform that action at this time.
0 commit comments