Skip to content

Latest commit

 

History

History
executable file
·
23 lines (10 loc) · 513 Bytes

Maximum_Subset_Sum_With_No_Adjacent_Element.md

File metadata and controls

executable file
·
23 lines (10 loc) · 513 Bytes

Maximum Subset Sum With No Adjacent Elements

Problem Statement

Write a function that takes in an array of positive integers and returns an integer representing the maximum sum of non-adjacent elements in the array. If a sum cannot be generated, the function should return 0.

Sample input: [75, 105, 120, 75, 90, 135] Sample output: 330 (75, 120, 135)

Explanation

We can use a Stack here

Solution

Check this Python code.