Package g0801_0900.s0887_super_egg_drop
Class Solution
java.lang.Object
g0801_0900.s0887_super_egg_drop.Solution
887 - Super Egg Drop.<p>Hard</p>
<p>You are given <code>k</code> identical eggs and you have access to a building with <code>n</code> floors labeled from <code>1</code> to <code>n</code>.</p>
<p>You know that there exists a floor <code>f</code> where <code>0 <= f <= n</code> such that any egg dropped at a floor <strong>higher</strong> than <code>f</code> will <strong>break</strong> , and any egg dropped <strong>at or below</strong> floor <code>f</code> will <strong>not break</strong>.</p>
<p>Each move, you may take an unbroken egg and drop it from any floor <code>x</code> (where <code>1 <= x <= n</code>). If the egg breaks, you can no longer use it. However, if the egg does not break, you may <strong>reuse</strong> it in future moves.</p>
<p>Return <em>the <strong>minimum number of moves</strong> that you need to determine <strong>with certainty</strong> what the value of</em> <code>f</code> is.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> k = 1, n = 2</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong></p>
<p>Drop the egg from floor 1. If it breaks, we know that f = 0.</p>
<p>Otherwise, drop the egg from floor 2.</p>
<p>If it breaks, we know that f = 1. If it does not break, then we know f = 2.</p>
<p>Hence, we need at minimum 2 moves to determine with certainty what the value of f is.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> k = 2, n = 6</p>
<p><strong>Output:</strong> 3</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> k = 3, n = 14</p>
<p><strong>Output:</strong> 4</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= k <= 100</code></li>
<li><code>1 <= n <= 10<sup>4</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
superEggDrop
public int superEggDrop(int k, int n)
-