2023-09-07力扣每日一题

链接:

[2594. 修车的最少时间](https://leetcode.cn/problems/minimum-time-to-repair-cars/)\](https://leetcode.cn/problems/form-smallest-number-from-two-digit-arrays/) **题意:** 一个能力R的人R\*N\*N分钟修N辆车,求最快多久修完(多人多车) **解:** 二分很好想,主要是怎么检查(数学废物润去看题解了) **实际代码:** ```c++ long long repairCars(vector& ranks, int cars) { typedef long long int ll; sort(ranks.begin(),ranks.end()); ll l=1,r=1ll*ranks[ranks.size()-1]*pow(cars,2); while(l>1; ll cnt=0; for(auto rank:ranks) cnt+=sqrt(m/rank); if(cnt>=cars) r=m; else l=m+1; } return l; } ``` 限制: * `1 <= ranks.length <= 105` * `1 <= ranks[i] <= 100` * `1 <= cars <= 106`

相关推荐
X在敲AI代码1 天前
【无标题】
算法·leetcode·职场和发展
月明长歌1 天前
【码道初阶】Leetcode136:只出现一次的数字:异或一把梭 vs HashMap 计数(两种解法完整复盘)
java·数据结构·算法·leetcode·哈希算法
Swift社区1 天前
LeetCode 456 - 132 模式
java·算法·leetcode
LYFlied1 天前
【每日算法】LeetCode 152. 乘积最大子数组(动态规划)
前端·算法·leetcode·动态规划
圣保罗的大教堂1 天前
leetcode 3075. 幸福值最大化的选择方案 中等
leetcode
Dream it possible!1 天前
LeetCode 面试经典 150_回溯_单词搜索(104_79_C++_中等)
c++·leetcode·面试·回溯
2401_841495641 天前
【LeetCode刷题】杨辉三角
数据结构·python·算法·leetcode·杨辉三角·时间复杂度·空间复杂度
LYFlied1 天前
【每日算法】LeetCode 62. 不同路径(多维动态规划)
前端·数据结构·算法·leetcode·动态规划
yaoh.wang1 天前
力扣(LeetCode) 119: 杨辉三角 II - 解法思路
数据结构·python·算法·leetcode·面试·职场和发展·跳槽
2401_841495641 天前
【LeetCode刷题】爬楼梯
数据结构·python·算法·leetcode·动态规划·滑动窗口·斐波那契数列