Skip to content

Commit 7a7ac15

Browse files
authored
Create find-greatest-common-divisor-of-array.cpp
1 parent 167a551 commit 7a7ac15

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Time: O(n)
2+
// Space: O(1)
3+
4+
class Solution {
5+
public:
6+
int findGCD(vector<int>& nums) {
7+
return gcd(*min_element(cbegin(nums), cend(nums)),
8+
*max_element(cbegin(nums), cend(nums)));
9+
}
10+
};

0 commit comments

Comments
 (0)