leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1884.cpp (271B)


      1 class Solution {
      2     int dp[1001] = {0};
      3 
      4   public:
      5     int twoEggDrop(int n) {
      6         if (dp[n]) return dp[n];
      7         int res = n;
      8         for (int i = 1; i <= n; i++)
      9             res = min(res, 1 + max(i - 1, twoEggDrop(n - i)));
     10         return dp[n] = res;
     11     }
     12 };