aboutsummaryrefslogtreecommitdiffstats
path: root/1672/main.cpp
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2022-04-04 20:32:19 +0000
committerterminaldweller <thabogre@gmail.com>2022-04-04 20:32:19 +0000
commitbee546b9efce8f576c85ecca70c896074a918468 (patch)
tree322c685eaee3841736479a016f4efd8d5fd15096 /1672/main.cpp
parentupdate (diff)
downloadleetcode-bee546b9efce8f576c85ecca70c896074a918468.tar.gz
leetcode-bee546b9efce8f576c85ecca70c896074a918468.zip
update
Diffstat (limited to '')
-rw-r--r--1672/main.cpp28
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;
+}