-
[LeetCode] 1672. Richest Customer Wealth알고리즘 2022. 4. 24. 00:08
[LeetCode] 1672. Richest Customer Wealth
풀이_#1
class Solution(object): def maximumWealth(self, accounts): """ :type accounts: List[List[int]] :rtype: int """ n = [sum(accounts[i]) for i in range(len(accounts))] n.sort() return n[-1]
풀이_#2
map 을 사용한 짧고 멋진 풀이
class Solution(object): def maximumWealth(self, accounts): """ :type accounts: List[List[int]] :rtype: int """ return max(map(sum, accounts))
'알고리즘' 카테고리의 다른 글
[LeetCode] 704. Binary Search (0) 2022.04.24 [LeetCode] 234. Palindrome Linked List (0) 2022.04.24 [LeetCode] 1342. Number of Steps to Reduce a Number to Zero (0) 2022.04.23 [LeetCode] The K Weakest Rows in Matrix (0) 2022.04.23 [LeetCode] Middle of the Linked List (0) 2022.04.23