Apple | Phone | Maximum sum of non adjacent elements
Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2020-06-23Added By Anonymous
Source: Link
There is unsorted integer array, return a maximum sum of non adjacent elements.
example>
[5, 20, 15, -2, 18] => 20 + 18 = 38
[4, 1, 6, 3, 2] => 4 + 6 + 2 = 12
I never seen this problem in leetcode, anybody pls let me know how to approach this.
•I googled it and the solution seems different when the negative number exists or not.