From 1cdbbcaf73cbd6a35001d8c27735ffc09363e8e6 Mon Sep 17 00:00:00 2001 From: eat-swap Date: Thu, 14 Apr 2022 20:17:55 +0800 Subject: [PATCH] add: 220414-CN (2) [cpp] --- cpp/2204/220414-CN.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cpp/2204/220414-CN.cpp b/cpp/2204/220414-CN.cpp index e616143..deeecc6 100644 --- a/cpp/2204/220414-CN.cpp +++ b/cpp/2204/220414-CN.cpp @@ -4,4 +4,18 @@ * A customer's wealth is the amount of money they have in all their bank accounts. The richest customer is the customer that has the maximum wealth. * * Refer: 2201/220131.cpp - */ \ No newline at end of file + * 100% STL implementation this time! + */ + +#include +#include +#include + +class Solution { +public: + static int maximumWealth(const std::vector>& accounts) { + std::vector tmp; + std::for_each(accounts.cbegin(), accounts.cend(), [&](const std::vector& x) { tmp.push_back(std::accumulate(x.cbegin(), x.cend(), 0)); }); + return *std::max_element(tmp.cbegin(), tmp.cend()); + } +};