From d43724db3669e8864730cf474b949ca29d365c65 Mon Sep 17 00:00:00 2001 From: Devipriya <36542167+cadwellh5@users.noreply.github.com> Date: Fri, 2 Oct 2020 17:20:07 +0530 Subject: [PATCH] Maximum sum of increasing subsequence if input is {1, 101, 2, 3, 100, 4, 5}, then output should be 106 (1 + 2 + 3 + 100), if the input array is {3, 4, 5, 10}, then output should be 22 (3 + 4 + 5 + 10) if the input array is {10, 5, 4, 3}, then output should be 10 --- MaxSumOfIncreasinSubsequence | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 MaxSumOfIncreasinSubsequence diff --git a/MaxSumOfIncreasinSubsequence b/MaxSumOfIncreasinSubsequence new file mode 100644 index 0000000..a7cf714 --- /dev/null +++ b/MaxSumOfIncreasinSubsequence @@ -0,0 +1,16 @@ +ts=int(input()) +l3=[] +l1=[] +for j in range (ts): + n=int(input()) + l3.clear() + li=list(map(int, input().split())) + for i in range(1,n): + t=li[i-1] + for j in range(0,i): + if(li[i]>li[j]): + t=t+li[j] + l3.append(t) + if(len(l3)!=0): + print (max(l3)) + li.clear()