Skip to content

Commit bb7b408

Browse files
authored
Update find-triangular-sum-of-an-array.cpp
1 parent 073cdf8 commit bb7b408

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

C++/find-triangular-sum-of-an-array.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55
class Solution {
66
public:
77
int triangularSum(vector<int>& nums) {
8-
const auto& inv_mod = [](const auto& x, const auto& mod) {
9-
int y = x;
10-
while (y * x % 10 != 1) {
11-
y = y * x % 10;
12-
}
13-
return y;
14-
};
158
const auto& exp_mod = [](const auto& p, const auto& mod) {
169
vector<int> result = {p};
1710
while (result.back() * p % 10 != result[0]) {
@@ -20,6 +13,13 @@ class Solution {
2013
rotate(rbegin(result), rbegin(result) + 1, rend(result));
2114
return result;
2215
};
16+
const auto& inv_mod = [](const auto& x, const auto& mod) {
17+
int y = x;
18+
while (y * x % 10 != 1) {
19+
y = y * x % 10;
20+
}
21+
return y;
22+
};
2323
const auto& factor_p = [](auto x, const auto& p, auto cnt, auto diff) {
2424
if (x == 0) {
2525
return make_pair(x, cnt);

0 commit comments

Comments
 (0)