Skip to content

Commit 4d90d58

Browse files
committed
Added Maximum Sum of Non-Adjacent Elements Algorithm
1 parent 06c996e commit 4d90d58

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/main/java/com/thealgorithms/dynamicprogramming/MaxSumNonAdjacent.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ static int solveUtil(int index, int[] arr, int[] dp) {
3737

3838
static int solve(int n, int[] arr) {
3939
int[] dp = new int[n];
40-
41-
Arrays.fill(dp, -1);
40+
for (int i = 0; i < n; i++) dp[i] = -1;
4241

4342
return solveUtil(n - 1, arr, dp);
4443
}

0 commit comments

Comments
 (0)