Skip to content

Commit aa83bd2

Browse files
committed
Runtime: 74 ms (Top 32.31%) | Memory: 42.5 MB (Top 12.73%)
1 parent cb057ab commit aa83bd2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

scripts/algorithms/E/Egg Drop With 2 Eggs and N Floors/Egg Drop With 2 Eggs and N Floors.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
// Runtime: 74 ms (Top 32.31%) | Memory: 42.5 MB (Top 12.73%)
12
class Solution {
23
public int twoEggDrop(int n) {
34
int egg = 2; // hard coded to 2 eggs for this problem
45
int[][] dp = new int[n+1][egg+1];
56
return eggDrop(n, egg, dp);
67
}
7-
8+
89
int eggDrop(int n, int egg, int[][] dp) {
910
if(n <= 2 || egg == 1) return n;
1011
if(dp[n][egg] != 0) return dp[n][egg];
@@ -18,4 +19,4 @@ int eggDrop(int n, int egg, int[][] dp) {
1819
dp[n][egg] = min;
1920
return min;
2021
}
21-
}
22+
}

0 commit comments

Comments
 (0)