You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the ith customer has in the jth bank. Return the wealth that the richest customer has.
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.
- Use inbuilt accumulate function to get the sum of all the elements in the array
- TIP: use &x instead of only x, because it become faster to access with address
class Solution {
public:
int maximumWealth(vector<vector<int>>& accounts) {
int ans = 0;
for(auto &x:accounts){
int temp = accumulate(x.begin(),x.end(),0);
ans = max(temp,ans);
}
return ans;
}
};