add: 220414-CN (3) [cpp]

This commit is contained in:
eat-swap 2022-04-14 20:19:47 +08:00
parent 1cdbbcaf73
commit 8547278853
No known key found for this signature in database
GPG Key ID: 8C089CB1A2B7544F
1 changed files with 3 additions and 3 deletions

View File

@ -14,8 +14,8 @@
class Solution {
public:
static int maximumWealth(const std::vector<std::vector<int>>& accounts) {
std::vector<int> tmp;
std::for_each(accounts.cbegin(), accounts.cend(), [&](const std::vector<int>& x) { tmp.push_back(std::accumulate(x.cbegin(), x.cend(), 0)); });
return *std::max_element(tmp.cbegin(), tmp.cend());
int ret = 0;
std::for_each(accounts.cbegin(), accounts.cend(), [&](const std::vector<int>& x) { ret = std::max(ret, std::accumulate(x.cbegin(), x.cend(), 0)); });
return ret;
}
};