""" 1672.1 - Richest Customer Wealth - Solution 1 - Iterative Sum with Max """
#####################################################################################
# Imports
#####################################################################################
from typing import List
#####################################################################################
# Classes
#####################################################################################
class Solution:
"""Solution Class"""
def maximumWealth(self, accounts: List[List[int]]) -> int:
"""Maximum Wealth Function"""
max_wealth = 0
for customer in accounts:
wealth = 0
for account in customer:
wealth += account
max_wealth = max(max_wealth, wealth)
return max_wealth
#####################################################################################
# Functions
#####################################################################################
def testcase():
"""Test Function"""
print(Solution().maximumWealth([[1, 2, 3], [3, 2, 1]]))
print(Solution().maximumWealth([[1, 5], [7, 3], [3, 5]]))
print(Solution().maximumWealth([[2, 8, 7], [7, 1, 3], [1, 9, 5]]))
#####################################################################################
# Main
#####################################################################################
if __name__ == "__main__":
testcase()
""" 1672.2 - Richest Customer Wealth - Solution 2 - Pythonic One-Liner """
#####################################################################################
# Imports
#####################################################################################
from typing import List
#####################################################################################
# Classes
#####################################################################################
class Solution:
"""Solution Class"""
def maximumWealth(self, accounts: List[List[int]]) -> int:
"""Maximum Wealth Function"""
return max(sum(customer) for customer in accounts)
#####################################################################################
# Functions
#####################################################################################
def testcase():
"""Test Function"""
print(Solution().maximumWealth([[1, 2, 3], [3, 2, 1]]))
print(Solution().maximumWealth([[1, 5], [7, 3], [3, 5]]))
print(Solution().maximumWealth([[2, 8, 7], [7, 1, 3], [1, 9, 5]]))
#####################################################################################
# Main
#####################################################################################
if __name__ == "__main__":
testcase()
""" 1672.3 - Richest Customer Wealth - Solution 3 - Using map() """
#####################################################################################
# Imports
#####################################################################################
from typing import List
#####################################################################################
# Classes
#####################################################################################
class Solution:
"""Solution Class"""
def maximumWealth(self, accounts: List[List[int]]) -> int:
"""Maximum Wealth Function"""
return max(map(sum, accounts))
#####################################################################################
# Functions
#####################################################################################
def testcase():
"""Test Function"""
print(Solution().maximumWealth([[1, 2, 3], [3, 2, 1]]))
print(Solution().maximumWealth([[1, 5], [7, 3], [3, 5]]))
print(Solution().maximumWealth([[2, 8, 7], [7, 1, 3], [1, 9, 5]]))
#####################################################################################
# Main
#####################################################################################
if __name__ == "__main__":
testcase()