diff --git a/17EGICS031_ARRAY_8 b/17EGICS031_ARRAY_8 new file mode 100644 index 0000000..9293d66 --- /dev/null +++ b/17EGICS031_ARRAY_8 @@ -0,0 +1,23 @@ + Given an array of positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should not + #be adjacent in the array. + + +list=[] +n=int(input("Enter the size:")) +maxi=0 +for i in range(n): + ele=int(input()) + list.append(ele) +inc=0 +exc=0 +for i in range(n): + if exc > inc: + new_exc = exc + else: + new_exc = inc + inc = exc + list[i] + exc = new_exc +if exc > inc: + print (exc) +else: + print (inc)