There was an error while loading. Please reload this page.
1 parent fa1add2 commit bf5a61bCopy full SHA for bf5a61b
src/main/java/main/java/videos/EggSolver.java
@@ -19,8 +19,8 @@ public int solveUsingDp(int n, int k) {
19
for (int j = 2; j < k + 1; j++) {
20
results[i][j] = Integer.MAX_VALUE;
21
for (int x = 1; x < i; x++) {
22
- final int brokenEggResult = results[x - 1][k - 1];
23
- final int EggSurvivedResult = results[i - x][k];
+ final int brokenEggResult = results[x - 1][j - 1];
+ final int EggSurvivedResult = results[i - x][j];
24
int temp = Math.max(brokenEggResult, EggSurvivedResult) + 1;
25
if (temp < results[i][j]) {
26
results[i][j] = temp;
@@ -33,4 +33,4 @@ public int solveUsingDp(int n, int k) {
33
}
34
return results[n][k];
35
36
-}
+}
0 commit comments