You are viewing a single comment's thread. Return to all comments →
def maxSubsetSum(arr): n = len(arr) if(n==0): return 0 if(n==1): return arr[0] if(n==2): return max(arr[0],arr[1]) dp1 = 0 dp2 = 0 for num in arr: temp = max(dp1+num, dp2) dp1 = dp2 dp2 = temp return dp2
Seems like cookies are disabled on this browser, please enable them to open this website
Max Array Sum
You are viewing a single comment's thread. Return to all comments →