Try   HackMD

Leetcode 1672. Richest Customer Wealth

tags: Leetcode(JAVA)

題目 : https://leetcode.com/problems/richest-customer-wealth/

想法 :

​​​​語法。

時間複雜度 : O(n*m)。

程式碼 : (JAVA)

class Solution {
    public int maximumWealth(int[][] accounts) {
        int ans = -1, r = accounts.length;
        
        for(int i = 0 ; i < r ; i++){
            int sum = 0;
            for(int j = 0 ; j < accounts[i].length ; j++){
                sum += accounts[i][j];
            }    
            ans = Math.max(ans, sum);
        }
        
        return ans;
    }
}