class Solution: @lru_cache() def superEggDrop(self, K: int, N: int) -> int: if K == 1: return N if N == 0 or N == 1: return N ans = N # 暴力枚举从第 i 层开始扔 for i in range(1, N + 1): ans = min(ans, max(self.superEggDrop(K - 1,...
1//N层楼中扔鸡蛋,找到最坏情况下,鸡蛋恰好不碎的楼层,所需的最少实验次数2classSolution {3public:4intsuperEggDrop(intK,intN)5{6memo.clear();7returndp(K,N);8}9private:10intdp(intK,intN)11{12//base case13if(K==1)returnN;14if(N==0)return0;15//检索备忘录,若备忘录中有相应的状态...
https://leetcode.com/problems/super-egg-drop/discuss/159055/Java-DP-solution-from-O(KN2)-to-O(KNlogN)
鸡蛋掉落详解 Super Egg Drop · Issue #42 · Shellbye/Shellbye.github.iogithub.com/Shellbye/Shellbye.github.io/issues/42 https://www.youtube.com/watch?v=iOaRjDT0vjc&list=PLiQ766zSC5jM2OKVr8sooOuGgZkvnOCTI&index=3&t=0swww.youtube.com/watch?v=iOaRjDT0vjc&list=PLiQ766zSC5jM...
https://leetcode.com/problems/super-egg-drop/ 你将获得 T 个鸡蛋,并可以使用一栋从 1 到 N 共有 N 层楼的建筑。 每个蛋的功能都是一样的,如果一个蛋碎了,你就不能再把它掉下去。 你知道存在楼层 F ,满足 0 <= F <= N 任何从高于 F 的楼层落下的鸡蛋都会碎,从 F 楼层或比它低的楼层落...
* https://leetcode-cn.com/problems/super-egg-drop/description/ * * algorithms * Hard (28.88%) * Likes: 622 * Dislikes: 0 * Total Accepted: 43K * Total Submissions: 148.9K * Testcase Example: '1\n2' * * 给你 k 枚相同的鸡蛋,并可以使用一栋从第 1 层到第 n 层共有 n 层楼的建...
887 Super Egg Drop 鸡蛋掉落 Description: You are given k identical eggs and you have access to a building with n floors labeled from 1 to n. 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 drop...
usestd::collections::HashMap;implSolution{pubfnsuper_egg_drop(k:i32,n:i32)->i32{letmutdp:Vec<Vec<i32>>=vec![vec![0;(n+1)asusize];(k+1)asusize];let(muthit,mutcall)=(0,0);let(mut_k,mut_t)=(1,0);lett=loop{_t+=1;while_kasi32<=k{call+=1;if_k==1{dp[_k][_t]=...
94.扔鸡蛋(Super Egg Drop) 95.让数组唯一的最小增量(Minimum Increment to Make Array Unique) 96.比特位计数(Counting Bits) 97.完全二叉树的节点个数(Count Complete Tree Nodes) 98.目标和(Target Sum) 99.抵达第n个解方案的数量(Number of Dice Rolls With Target Sum) 100.找出第K大的异或坐标值(Fi...
887 Super Egg Drop 24.90% Hard 886 Possible Bipartition 40.90% Medium 885 Spiral Matrix III 64.80% Medium 884 Uncommon Words from Two Sentences 60.90% Easy 883 Projection Area of 3D Shapes 65.90% Easy 882 Reachable Nodes In Subdivided Graph 38.20% Hard 881 Boats to Save People 44.10% Medium ...