Skip to content

Commit 2f203d2

Browse files
committed
Mod: Dynamic Programming - LIS & BB::maxLen defaults to 1
1 parent 5a30fce commit 2f203d2

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

DynamicProgramming/BuildingBridges/Solution.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public int buildingBridges(int[][] cityPairs) {
2929
* * SC: O(n)
3030
*/
3131
private int longestIncreasingSubsequenceDP(int[][] cityPairs) {
32-
int len = cityPairs.length, maxLen = Integer.MIN_VALUE;
32+
int len = cityPairs.length, maxLen = 1;
3333
int[] dp = new int[len];
3434
Arrays.fill(dp, 1);
3535

@@ -44,7 +44,7 @@ private int longestIncreasingSubsequenceDP(int[][] cityPairs) {
4444
}
4545
}
4646

47-
return dp[len - 1];
47+
return maxLen;
4848
}
4949

5050
/**

DynamicProgramming/LongestIncreasingSubsequence/Solution.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public int longestIncreasingSubsequence(int[] items) {
2626
* * SC: O(n)
2727
*/
2828
private int longestIncreasingSubsequenceDP(int[] items) {
29-
int len = items.length, maxLen = Integer.MIN_VALUE, end = 0;
29+
int len = items.length, maxLen = 1, end = 0;
3030
int[] dp = new int[len];
3131
Arrays.fill(dp, 1);
3232

0 commit comments

Comments
 (0)