pratik-choudhari / AlgoCode

Welcome everyone!🌟 Here you can solve problems, build scrappers and much more💻
https://github.com/pratik-choudhari/AlgoCode
MIT License
131 stars 166 forks source link

Max Array Sum #327

Closed pallavivaswani closed 3 years ago

pallavivaswani commented 3 years ago

Feature ✅

Description

Given an array of integers, find the subset of non-adjacent elements with the maximum sum. Calculate the sum of that subset. For example, given an array [-2,1,3,-4,5] we have the following possible subsets: Subset Sum
[-2, 3, 5] 6
[-2, 3] 1
[-2, -4] -6
[-2, 5] 3
[1, -4] -3
[1, 5] 6
[3, 5] 8

Our maximum subset-sum is 8.

Example

Input Format

The first line contains an integer, n. The second line contains n space-separated integers arr[i].

Output Format

Return the maximum sum described in the statement.

Input

5 3 7 4 6 5

Output

13

Explanation

Our possible subsets are [3,4,5], [3,4], [3,6], [3,5], [7,5], [7,6] and [4,5]. The largest subset sum is 13 from subset [7,6]

Checklist:

Contributors are supposed to mention their coding language while asking for assignment

EANimesha commented 3 years ago

I like to complete this in python

therupdeep commented 3 years ago

@pallavivaswani i would like to do this in Java. Could you assign it to me?

Isha2208 commented 3 years ago

Hey, @pallavivaswani I would like to contribute in C/C++ language

Harshalszz commented 3 years ago

Hey! can I work on this in C++.

coreprogrammar commented 3 years ago

I would like to complete this in C++