• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
May 13, 2022 |29.9K Views
Maximum sum such that no two elements are adjacent
  Share  2 Likes
Description
Discussion

Given an array arr[] of positive numbers, the task is to find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be adjacent in the array.

Examples:

Input: arr[] = {5, 5, 10, 100, 10, 5}
Output: 110
Explanation: Pick the subsequence {5, 100, 5}.
The sum is 110 and no two elements are adjacent. This is the highest possible sum.

Maximum sum such that no two elements are adjacent: https://www.geeksforgeeks.org/maximum-sum-such-that-no-two-elements-are-adjacent/

Read More