Given a sequence of numbers, you have to find the maximum sum alternating subsequence and print the value
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
Let N be the number of elements say, X1, X2, X3, ..., Xn
Let f(a) = the value at the index a of the increasing array, and g(a) = the value at the index a of the decreasing array.
To find out the maximum sum alternating sequence we will follow these steps,
f(indexofthecurrentelement) = max
g(indexofthecurrentelement) = max
C++ Implementation:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer