1672. Richest Customer Wealth

仅供自己学习

 

思路:

直接双重for遍历即可,每次用一个变量存储,然后每次取max。

 1 class Solution {
 2 public:
 3     int maximumWealth(vector<vector<int>>& accounts) {
 4         int maxaccunt=INT_MIN;
 5         int temp=0;
 6         for(auto& ac:accounts){
 7             for(auto& all:ac){
 8                 temp+=all;
 9             }
10             maxaccunt=max(maxaccunt,temp);
11             temp=0;
12         }
13         return maxaccunt;
14     }
15 };

 

posted @ 2021-03-26 10:41  Mrsdwang  阅读(45)  评论(0)    收藏  举报