作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 参考资料 日期 题目地址:https://leetcode.com/problems/super-egg-drop/description/ 题目描述 You are given K eggs, and you have access to a building with N floors from 1 to N. Each egg is ident…
You are given K eggs, and you have access to a building with N floors from 1 to N.  Each egg is identical in function, and if an egg breaks, you cannot drop it again. You know that there exists a floor F with 0 <= F <= N such that any egg dropped at…
题目链接:https://leetcode.com/problems/super-egg-drop/ 题意:给你K个鸡蛋以及一栋N层楼的建筑,已知存在某一个楼层F(0<=F<=N),在不高于F的楼层扔鸡蛋不会碎,鸡蛋碎了不能再用,没碎可以继续使用,问不论F的大小(0<=F<=N),至少需要测量多少次才能测出F的大小.题意挺好理解的,鸡蛋少的话操作肯定多点,相当于行下往上测,鸡蛋比较多就可以使用类似二分的想法了. 思路1: dp+二分  时间复杂度O(K*N*log N),空间复杂度…
这是经典的扔鸡蛋的题目. 同事说以前在uva上见过,不过是扔气球.题意如下: 题意: 你有K个鸡蛋,在一栋N层高的建筑上,被要求测试鸡蛋最少在哪一层正好被摔坏. 你只能用没摔坏的鸡蛋测试.如果一个鸡蛋在上一次测试中没有被摔坏,那么你可以重复使用,否则,你只能用下一个鸡蛋. 需要求,最小的步数,使得你在这么多步内一定测试出结果. 思路: O(K * N^2) 首先,这个题比较绕.需要求一个最优决策使得步数最小,但是实际的步数是随着真实结果变化而变化的. 于是,为了保证在我们假设的步数内一定能够解完…
You are given K eggs, and you have access to a building with N floors from 1 to N. Each egg is identical in function, and if an egg breaks, you cannot drop it again. You know that there exists a floor F with 0 <= F <= N such that any egg dropped at…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/unique-paths/description/ 题目描述: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either…
[LeetCode]376. Wiggle Subsequence 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/wiggle-subsequence/description/ 题目描述: A sequence of numbers is called a wiggle sequence if the differences betw…
[LeetCode]649. Dota2 Senate 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/dota2-senate/description/ 题目描述: In the world of Dota2, there are two parties: the Radiant and the Dire. The Dota2 sena…
[LeetCode]911. Online Election 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/online-election/description/ 题目描述: In an election, the i-th vote was cast for persons[i] at time times[i]. Now, we…
[LeetCode]886. Possible Bipartition 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/possible-bipartition/description/ 题目描述: Given a set of N people (numbered 1, 2, ..., N), we would like to spli…