1672. Richest Customer Wealth

problem

solution

1
2
3
4
5
6
7
8
9
10
11
12
class Solution {
public:
int maximumWealth(vector<vector<int>>& accounts) {
int mx = 0, n= accounts.size();
for(int i=0;i<n;++i){
int temp = 0;
for(auto a:accounts[i]) temp+=a;
mx = max(mx, temp);
}
return mx;
}
};

analysis

  • time complexity O(nm)
  • space complexity O(1)