Skip to content

Commit 6702fd0

Browse files
committed
fix: correct MaximumProductSubarray compilation errors
1 parent ec2ac89 commit 6702fd0

File tree

1 file changed

+0
-27
lines changed

1 file changed

+0
-27
lines changed

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

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -52,33 +52,6 @@ public static int maxProduct(int[] nums) {
5252
}
5353
}
5454

55-
/**
56-
* Finds the maximum product using a memoization approach with recursion.
57-
* This method explores all possible subarrays and stores intermediate results.
58-
*
59-
* @param nums an array of integers which may contain positive, negative,
60-
* and zero values.
61-
* @return the maximum product of a contiguous subarray. Returns 0 if the
62-
* array is empty.
63-
*/
64-
public static int maxProductMemoized(int[] nums) {
65-
if (nums == null || nums.length == 0) {
66-
return 0;
67-
}
68-
69-
int n = nums.length;
70-
Integer[][] memo = new Integer[n][n];
71-
int maxProduct = Integer.MIN_VALUE;
72-
73-
for (int i = 0; i < n; i++) {
74-
for (int j = i; j < n; j++) {
75-
maxProduct = Math.max(maxProduct, calculateProduct(nums, memo, i, j));
76-
}
77-
}
78-
79-
return maxProduct;
80-
}
81-
8255
/**
8356
* A recursive helper method to calculate the product of elements from index
8457
* start to index end using memoization.

0 commit comments

Comments
 (0)