细读example 2:
One optimal strategy is:

  • Drop the 1st egg at floor 9. If it breaks, we know f is between 0 and 8. Drop the 2nd egg starting from floor 1 and going up one at a time to find f within 8 more drops. Total drops is 1 + 8 = 9.
  • If the 1st egg does not break, drop the 1st egg again at floor 22. If it breaks, we know f is between 9 and 21. Drop the 2nd egg starting from floor 10 and going up one at a time to find f within 12 more drops. Total drops is 2 + 12 = 14.
  • If the 1st egg does not break again, follow a similar process dropping the 1st egg from floors 34, 45, 55, 64, 72, 79, 85, 90, 94, 97, 99, and 100.
    Regardless of the outcome, it takes at most 14 drops to determine f.
class Solution:def twoEggDrop(self, n: int) -> int:count = 0wh_condition = nwhile wh_condition > 0:count += 1wh_condition -= countreturn count#dropAtFloors = [9,22,34,45,55,64,72,79,85,90,94,97,99,100]
#(gap)         8 13 12 11 10 9  8  7  6  5  4  3  2  1

Leetcode 1884. Egg Drop With 2 Eggs and N Floors [Python]相关推荐

  1. 【LeetCode】222. Count Complete Tree Nodes 解题报告(Python)

    [LeetCode]222. Count Complete Tree Nodes 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个 ...

  2. LeetCode 887. Super Egg Drop

    题目链接:https://leetcode.com/problems/super-egg-drop/ 题意:给你K个鸡蛋以及一栋N层楼的建筑,已知存在某一个楼层F(0<=F<=N),在不高 ...

  3. Coursera Algorithms week1 算法分析 练习测验: Egg drop 扔鸡蛋问题

    题目原文: Suppose that you have an n-story building (with floors 1 through n) and plenty of eggs. An egg ...

  4. 【数据结构与算法】动态规划-leetcode.1884 鸡蛋掉落两枚鸡蛋

    [题目]: 给你 2 枚相同 的鸡蛋,和一栋从第 1 层到第 n 层共有 n 层楼的建筑. 已知存在楼层 f ,满足 0 <= f <= n ,任何从 高于 f 的楼层落下的鸡蛋都 会碎 ...

  5. LeetCode 221. Maximal Square----动态规划--谷歌面试算法题--Python解法

    题目地址:Maximal Square - LeetCode Given a 2D binary matrix filled with 0's and 1's, find the largest sq ...

  6. LeetCode 445. Add Two Numbers II--面试算法题--C++,Python解法

    题目地址:Add Two Numbers II - LeetCode You are given two non-empty linked lists representing two non-neg ...

  7. LeetCode 17. Letter Combinations of a Phone Number--笔试题--C++,Python解法

    题目地址:Letter Combinations of a Phone Number - LeetCode Given a string containing digits from 2-9 incl ...

  8. LeetCode 746. Min Cost Climbing Stairs--动态规划--Java,C++,Python解法

    题目地址:Min Cost Climbing Stairs - LeetCode LeetCode 动态规划(Dynamic programming)系列题目:LeetCode 动态规划(Dynami ...

  9. LeetCode 121. Best Time to Buy and Sell Stock--Java,Python,C++解法

    题目地址:Best Time to Buy and Sell Stock - LeetCode Say you have an array for which the ith element is t ...

最新文章

  1. word 另存为xml后,读取xml的图片数据
  2. 整理了7道Python函数的练习题,希望对你学习函数有帮助
  3. 【Python】部分基础+Flask/JSON/....+零碎笔记
  4. 前端性能优化 Web前端应该从哪些方面来优化网站?
  5. 日期格式无法识别 oracle,Oracle时间统计 - 不以物喜-不以己悲的个人空间 - OSCHINA - 中文开源技术交流社区...
  6. windows mysqldump 不成功 1049 1064 报错
  7. 银联pos小票word模板_商家pos机刷卡必须知道的知识
  8. 网页设计 html鼠标悬停,利用css3实现的简单的鼠标悬停按钮
  9. Netsharp快速入门(之2) 基础档案(之A 创建插件和资源)
  10. 又忙了一天,什么书也不看。
  11. 2021-09-08推荐系统有如下三大类算法
  12. 高通 MSM 8916与MSM8926芯片的区别
  13. 国务院《新能源汽车产业发展规划(2021—2035年)》
  14. DS1302 的 BURST 模式
  15. Flutter生命周期
  16. rails gem devise
  17. 苹果笔记本计算机内存不足怎么办,苹果手机更新系统内存不够怎么处理-电脑内存不足怎么解决...
  18. 心法利器[53] | 数据增强的现实应用思考
  19. 使用jquery,按回车键实现tab键的功能
  20. 从Dinic到ISAP,从余流推进到最高标号的预留推进HLPP(究极最大流算法)

热门文章

  1. 悉尼科技大学ReLER实验室介绍
  2. mysql - innodb引擎
  3. 如何把 AI 格式的文件转换成 BMP或者JPEG?
  4. 《仙剑奇侠传》引发的爱情思考zz
  5. 芯动联科冲刺科创板:年营收1.7亿 北方电子院与中城创投是股东
  6. [八省联考 2018]林克卡特树
  7. Python编写微信打飞机小游戏(五)
  8. 工具使用-QQ/TIM(1)QQ/TIM客户端聊天窗口输入/自动变成表情 - 解决方案
  9. C语言实现简单的记忆力测试游戏
  10. js实现密码输入框点击小眼睛显示或隐藏密码