class Solution:
def maximumWealth(self, accounts: List[List[int]]) -> int:
def iterate(lst, start, end, res):
if start > end:
return res
else:
return iterate(lst, start + 1, end, max(sum(lst[start]), res))
return iterate(accounts, 0, len(accounts)-1, 0)
I was working on a leetcode question and figured I'd make it hard on myself, but indeed ended up getting stuck. My function returns "None" in place for res, but when I run the function "print(res)" it returns the value that I expect. Any reason why it's doing that? Heads up, I am new to recursion.
Thank you in advance.