887. Super Egg Drop Hard

@problem@discussion
#Math#Binary Search#Dynamic Programming



1/**
2 * [887] Super Egg Drop
3 *
4 * You are given k identical eggs and you have access to a building with n floors labeled from 1 to n.
5 * You know that there exists a floor f where 0 <= f <= n such that any egg dropped at a floor higher than f will break, and any egg dropped at or below floor f will not break.
6 * Each move, you may take an unbroken egg and drop it from any floor x (where 1 <= x <= n). If the egg breaks, you can no longer use it. However, if the egg does not break, you may reuse it in future moves.
7 * Return the minimum number of moves that you need to determine with certainty what the value of f is.
8 *  
9 * Example 1:
10 * 
11 * Input: k = 1, n = 2
12 * Output: 2
13 * Explanation: 
14 * Drop the egg from floor 1. If it breaks, we know that f = 0.
15 * Otherwise, drop the egg from floor 2. If it breaks, we know that f = 1.
16 * If it does not break, then we know f = 2.
17 * Hence, we need at minimum 2 moves to determine with certainty what the value of f is.
18 * 
19 * Example 2:
20 * 
21 * Input: k = 2, n = 6
22 * Output: 3
23 * 
24 * Example 3:
25 * 
26 * Input: k = 3, n = 14
27 * Output: 4
28 * 
29 *  
30 * Constraints:
31 * 
32 * 	1 <= k <= 100
33 * 	1 <= n <= 10^4
34 * 
35 */
36pub struct Solution {}
37
38// problem: https://leetcode.com/problems/super-egg-drop/
39// discuss: https://leetcode.com/problems/super-egg-drop/discuss/?currentPage=1&orderBy=most_votes&query=
40
41// submission codes start here
42
43impl Solution {
44    pub fn super_egg_drop(k: i32, n: i32) -> i32 {
45        0
46    }
47}
48
49// submission codes end
50
51#[cfg(test)]
52mod tests {
53    use super::*;
54
55    #[test]
56    fn test_887() {
57    }
58}
59


Back
© 2025 bowen.ge All Rights Reserved.