Welcome to the daily solving of our PROBLEM OF THE DAY with Siddharth Hazra. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Arrays but also build up problem-solving skills.
In this problem, given an array Arr of size N containing positive integers. Find the maximum sum of any possible subsequence such that no two numbers in the subsequence should be adjacent in Arr.
Example :
Input:
N = 6
Arr[] = {5, 5, 10, 100, 10, 5}
Output: 110
Explanation: If you take indices 0, 3 and 5, then Arr[0]+Arr[3]+Arr[5] =5+100+5 = 110.
Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/max-sum-without-adjacents2430/1