Maximum Sum Increasing Subsequence


/ Published in: Python
Save to your folder(s)

Dynamic Programming


Copy this code and paste it in your HTML
  1. arr = [1,101,2,3,100,4,5]
  2. msis = [elem for elem in arr]
  3.  
  4. for x in range(1,len(arr),1):
  5. for y in range(0,x,1):
  6. if arr[x] > arr[y]:
  7. msis[x] += arr[y]
  8.  
  9. print(max(msis))

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.