Java icon indicating copy to clipboard operation
Java copied to clipboard

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

Open Guhapriya01 opened this issue 1 year ago • 5 comments

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

Guhapriya01 avatar Oct 02 '24 07:10 Guhapriya01

Sure, go ahead and add it

siriak avatar Oct 02 '24 08:10 siriak

Thank you! I'll start working on it.

Guhapriya01 avatar Oct 02 '24 12:10 Guhapriya01

Please assign the task to me as a hacktoberfest contributor

Nandinig24 avatar Oct 06 '24 09:10 Nandinig24

Is task still open? if yes please assign the task to me as a hacktoberfest contributor

lfcbird avatar Oct 07 '24 13:10 lfcbird

Hi @Guhapriya01 , I hope you're doing well!

This is Veer, and I’m currently pursuing my master's degree. As part of one of my course assignments, I need to select a GitHub repository and contribute to it in some capacity. I came across your repository and would love to work on this particular issue.

It would be greatly appreciated if you could assign the issue to me and allow me to contribute. Please feel free to reach out if you have any questions or need further information from my side.

Thanks, Veer

KSVeerendernath avatar Oct 23 '24 13:10 KSVeerendernath

Added in #5544

siriak avatar Oct 23 '24 17:10 siriak