Example 1 doubt

hi, for Example 1, the sum is 31 but the program output is 32. How is the output 32?

Type your question above this line.


Hello @Ashish_D,

In example 1, there are two increasing sequences. First one is {1,2,6,10,12} whose sum is 31 and the second is {4,6,10,12} whose sum is 32. This makes {4,6,10,12} the increasing sequence with the highest sum and hence, the output will be 32 and not 31.

Hope this helps!