Skip to content

[FEATURE REQUEST] Add Maximum Sum of Non-Adjacent Elements Algorithm #5510

@Guhapriya01

Description

@Guhapriya01

What would you like to Propose?

I would like to propose adding an implementation of the Maximum Sum of Non-Adjacent Elements algorithm to the dynamic programming section of the repository.

Issue details

Problem Statement:
Given an array of integers, write a function to find the maximum sum of non-adjacent elements. The elements can be chosen such that no two chosen elements are adjacent in the array.

For example:
Input: [3, 2, 5, 10, 7]
Output: 15 (The maximum sum is obtained by selecting 3, 7, and 5)

Approach:

  1. Use dynamic programming to maintain a running maximum sum.
  2. For each element, decide to either include it in the sum (and skip the previous element) or exclude it (and keep the sum up to the previous element).

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions