diff options
author | terminaldweller <thabogre@gmail.com> | 2022-04-04 20:32:19 +0000 |
---|---|---|
committer | terminaldweller <thabogre@gmail.com> | 2022-04-04 20:32:19 +0000 |
commit | bee546b9efce8f576c85ecca70c896074a918468 (patch) | |
tree | 322c685eaee3841736479a016f4efd8d5fd15096 /1672/main.cpp | |
parent | update (diff) | |
download | leetcode-bee546b9efce8f576c85ecca70c896074a918468.tar.gz leetcode-bee546b9efce8f576c85ecca70c896074a918468.zip |
update
Diffstat (limited to '')
-rw-r--r-- | 1672/main.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/1672/main.cpp b/1672/main.cpp new file mode 100644 index 0000000..50397e9 --- /dev/null +++ b/1672/main.cpp @@ -0,0 +1,28 @@ +#include "header.hpp" +#include <algorithm> + +class Solution { +public: + static int maximumWealth(std::vector<std::vector<int>> &accounts) { + int i_max = 0; + int sum_max = 0; + int sum_cur = 0; + for (int i = 0; i < accounts.size(); ++i) { + for (int j = 0; j < accounts[i].size(); ++j) { + sum_cur += accounts[i][j]; + } + if (sum_cur > sum_max) { + sum_max = sum_cur; + i_max = i; + } + sum_cur = 0; + } + return sum_max; + } +}; + +int main(int argc, char **argv) { + std::vector<std::vector<int>> accounts = {{1, 2, 3}, {3, 2, 1}}; + std::cout << Solution::maximumWealth(accounts); + return 0; +} |