File tree 1 file changed +0
-21
lines changed
src/main/java/com/thealgorithms/dynamicprogramming 1 file changed +0
-21
lines changed Original file line number Diff line number Diff line change 1
1
package com .thealgorithms .dynamicprogramming ;
2
2
3
- import java .util .*;
4
-
5
3
/*
6
4
What would you like to Propose?
7
5
I would like to propose adding an implementation of the Maximum Sum of Non-Adjacent Elements
@@ -57,23 +55,4 @@ static int solve(int n, int[] arr) {
57
55
// Call the recursive solver for the last index (n-1).
58
56
return solveUtil (n - 1 , arr , dp );
59
57
}
60
-
61
- public static void main (String [] args ) {
62
- Scanner sc = new Scanner (System .in );
63
-
64
- // Input array size and elements.
65
- System .out .print ("Enter the size of the array: " );
66
- int n = sc .nextInt ();
67
- int [] nums = new int [n ];
68
- System .out .print ("Enter the elements of the array: " );
69
- for (int i = 0 ; i < n ; i ++) { nums [i ] = sc .nextInt (); }
70
-
71
- // Call the solve function to find the maximum possible sum.
72
- int ans = solve (n , nums );
73
-
74
- // Print the result.
75
- System .out .println ("Maximum sum of non-adjacent elements: " + ans );
76
-
77
- sc .close (); // Close the scanner to prevent resource leakage.
78
- }
79
58
}
You can’t perform that action at this time.
0 commit comments