Skip to content

Latest commit

 

History

History
20 lines (12 loc) · 784 Bytes

Max_Sum_Increasing_Subsequence.md

File metadata and controls

20 lines (12 loc) · 784 Bytes

Max Sum Increasing Subsequence

Problem Statement

Given an non-empty array of integers, write a function that returns an array of length 2. The rst element in the output array should be an integer value representing the greatest sum that can be generated from a strictly-increasing subsequence in the array. The second element should be an array of the numbers in that subsequence. A subsequence is dened as a set of numbers that are not necessarily adjacent but that are in the same order as they appear in the array. Assume that there will only be one increasing subsequence with the greatest sum.

Sample input: [10, 70, 20, 30, 50, 11, 30] Sample output: [110, [10, 20, 30, 50]]

Solution

Check this Python code.