leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
1884.cpp (271B)
0 class Solution {
1 int dp[1001] = {0};
3 public:
4 int twoEggDrop(int n) {
5 if (dp[n]) return dp[n];
6 int res = n;
7 for (int i = 1; i <= n; i++)
8 res = min(res, 1 + max(i - 1, twoEggDrop(n - i)));
9 return dp[n] = res;
10 }
11 };