File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed
check-if-it-is-a-good-array Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change 4
4
#include < vector>
5
5
6
6
using namespace std ;
7
- template <class InputIt , class T , class BinaryOperation >
8
- constexpr // since C++20
9
- T
10
- accumulate2 (InputIt first, InputIt last, T init, BinaryOperation op)
11
- {
12
- for (; first != last; ++first)
13
- init = op (std::move (init), *first); // std::move since C++11
7
+ // template <class InputIt, class T, class BinaryOperation>
8
+ // constexpr // since C++20
9
+ // T
10
+ // accumulate2(InputIt first, InputIt last, T init, BinaryOperation op)
11
+ // {
12
+ // for (; first != last; ++first)
13
+ // init = op(std::move(init), *first); // std::move since C++11
14
14
15
- return init;
16
- };
15
+ // return init;
16
+ // };
17
17
int gcd2 (int num1, int num2)
18
18
{
19
19
while (num2 != 0 ) {
@@ -28,7 +28,7 @@ class Solution {
28
28
public:
29
29
bool isGoodArray (vector<int >& nums)
30
30
{
31
- int divisor = accumulate2 (nums.begin (), nums.end (), nums[0 ], gcd2);
31
+ int divisor = accumulate (nums.begin (), nums.end (), nums[0 ], gcd2);
32
32
return divisor == 1 ;
33
33
}
34
34
};
You can’t perform that action at this time.
0 commit comments