当前位置:网站首页>[binary search - simple] LCP 18 Breakfast combination
[binary search - simple] LCP 18 Breakfast combination
2022-04-21 15:11:00 【Caicai 2022】
subject
Be careful : The answer needs to be 1e9 + 7 (1000000007) Take the mold for the bottom , Such as : The initial result of calculation is :1000000008, Please return 1
Tips :
1 <= staple.length <= 10^5
1 <= drinks.length <= 10^5
1 <= staple[i],drinks[i] <= 10^5
1 <= x <= 2*10^5
【 Code 】
Execution time :1064 ms, In all Python3 Defeated in submission 11.97% Users of
Memory consumption :28.6 MB, In all Python3 Defeated in submission 96.95% Users of
Pass the test case :65 / 65
class Solution:
def breakfastNumber(self, staple: List[int], drinks: List[int], x: int) -> int:
ans=0
staple.sort()
drinks.sort()
for item in staple:
# seek drinks Center left to right The first one is greater than >x-item Of Numeric subscript
if x-item<=0:
continue
left,right=0,len(drinks)-1
while left<=right:
mid=left+(right-left)//2
if drinks[mid]<=(x-item):
left=mid+1
else:
right=mid-1
ans+=left
return ans%(10**9 + 7 )
版权声明
本文为[Caicai 2022]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211507332804.html
边栏推荐
- 干货 | 应用打包还是测试团队老大难问题?
- 干货 | 移动端App自动化之App控件定位
- MySQL8.0零基础入门之从青铜到钻石
- SAP ui5 application development tutorial 70 - how to trigger page route jump using button control
- 解锁OpenHarmony技术日!年度盛会,即将揭幕!
- 【二分查找-简单】剑指 Offer II 068. 查找插入位置
- Lightgbm topic 2: detailed explanation of lightgbm training based on pyspark platform
- scala安装及环境配置
- 【二分搜索-中等】1498. 满足条件的子序列数目
- Mysql database (2)
猜你喜欢

SAP ui5 application development tutorial 70 - how to use button controls to trigger page routing jump trial version

基于JSP的公益网站设计与实现

scala安装及环境配置

MySQL下载和安装教程
![[today in history] April 21: microprocessor pioneer was born; Winamp release; Coppa comes into force](/img/71/6f61fb0d0a46a25d92bdb48d02f413.png)
[today in history] April 21: microprocessor pioneer was born; Winamp release; Coppa comes into force

尚硅谷智慧校园 —— 6、管理员功能实现

SAP ui5 application development tutorial 70 - how to trigger page route jump using button control

QT network and communication (TCP chat room)

阿里P9详解高并发,带你了解淘宝怎么抗住双11等大型秒杀活动

JD cloud has launched cloud computing to create an unbounded office experience for the future
随机推荐
Analysis on development mode of bounty hunter automatic Trading Robot
Service中是如何产生ANR的?
Deploy the big pit of edgemesh on kubesphere
Excel小技巧-VLOOKUP自动匹配
Spark SQL底层执行流程详解
武汉科技大学C语言上机实验题(第一第二第三部分)
Insect 12864
Lightgbm topic 2: detailed explanation of lightgbm training based on pyspark platform
【二分查找-简单】剑指 Offer II 072. 求平方根
【二分搜索-简单】LCP 28. 采购方案
干货 | 移动端App自动化之App控件定位
让阿里P8都为之着迷的分布式核心原理解析到底讲了啥?看完我惊了
干货 | 环境问题还是测试的老大难?两个步骤轻松搞定
[binary search - simple] 441 Arrange coins
lightGBM专题2:基于pyspark在spark平台下lightgbm训练详解
SQL性能优化以及性能测试
数据库基础知识详解五:MySQL中的索引和其两种引擎、主从复制以及关系型/非关系型数据库
Manually adjust slf4j the log level
二叉树的堂兄弟节点-c语言
想请问一下如何从数据库中找到软件注册码