Skip to content

Commit 5820539

Browse files
committed
namespace check_if_it_is_a_good_array
1 parent f9b5700 commit 5820539

File tree

2 files changed

+14
-29
lines changed

2 files changed

+14
-29
lines changed

check-if-it-is-a-good-array/index.hpp

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,18 @@ using namespace std;
77
#include <algorithm>
88
#include <numeric>
99

10-
1110
#include "gcd.hpp"
12-
// template <class InputIt, class T, class BinaryOperation>
13-
// constexpr // since C++20
14-
// T
15-
// accumulate2(InputIt first, InputIt last, T init, BinaryOperation op)
16-
//{
17-
// for (; first != last; ++first)
18-
// init = op(std::move(init), *first); // std::move since C++11
19-
20-
// return init;
21-
//};
22-
// int gcd(int num1, int num2)
23-
// {
24-
// while (num2 != 0) {
25-
// int temp = num1;
26-
// num1 = num2;
27-
// num2 = temp % num2;
28-
// }
29-
// return num1;
30-
// };
11+
namespace check_if_it_is_a_good_array
12+
{
3113

32-
class Solution {
33-
public:
34-
bool isGoodArray(vector<int> &nums) {
35-
int divisor = accumulate<std::vector<int>::iterator, int, int(int, int)>(
36-
nums.begin(), nums.end(), nums[0], gcd);
37-
return divisor == 1;
38-
}
39-
};
14+
class Solution
15+
{
16+
public:
17+
bool isGoodArray(vector<int> &nums)
18+
{
19+
int divisor = accumulate<std::vector<int>::iterator, int, int(int, int)>(
20+
nums.begin(), nums.end(), nums[0], gcd);
21+
return divisor == 1;
22+
}
23+
};
24+
}

check-if-it-is-a-good-array/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <iostream>
66

77
using namespace std;
8-
8+
using namespace check_if_it_is_a_good_array;
99
TEST(check_if_it_is_a_good_array, test1)
1010
{
1111
cout << "check-if-it-is-a-good-array" << endl;

0 commit comments

Comments
 (0)