Skip to content

Commit 2110aa5

Browse files
authored
Update largest-multiple-of-three.cpp
1 parent 3410b49 commit 2110aa5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

C++/largest-multiple-of-three.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Solution {
1212
unordered_map<int, int> count = counter(digits);
1313
const auto& total = accumulate(cbegin(digits), cend(digits), 0);
1414
for (const auto& deletes : lookup.at(total % 3)) {
15-
if (remove(deletes, total, &count)) {
15+
if (remove(deletes, &count)) {
1616
break;
1717
}
1818
}
@@ -24,9 +24,8 @@ class Solution {
2424
}
2525

2626
private:
27-
bool remove(const vector<int>& deletes, int total, unordered_map<int, int> *count) {
28-
if (accumulate(cbegin(deletes), cend(deletes), 0) % 3 == total % 3 &&
29-
all_of(cbegin(deletes), cend(deletes),
27+
bool remove(const vector<int>& deletes, unordered_map<int, int> *count) {
28+
if (all_of(cbegin(deletes), cend(deletes),
3029
[&count, &deletes](const auto& x) {
3130
return (*count)[x] >= std::count(cbegin(deletes), cend(deletes), x);
3231
})) {

0 commit comments

Comments
 (0)