leetcode-159周赛-5233-规划兼职工作*
方法:
class Solution:
def jobScheduling(self, startTime: List[int], endTime: List[int], profit: List[int]) -> int: idx=[i for i in range(len(startTime))] idx.sort(key=lambda i:endTime[i]) dp = [0 for i in range(len(startTime))]
dp[idx[0]]=profit[idx[0]]
for i in range(1,len(startTime)):
l=0
r=i-1 while(l<r):
mid = int((l+r+1)/2)
if(endTime[idx[mid]] > startTime[idx[i]]):
r=mid-1
else:
l=mid
if(endTime[idx[l]]<=startTime[idx[i]]):
dp[idx[i]]=max(dp[idx[l]]+profit[idx[i]],dp[idx[i-1]])
else:
dp[idx[i]]=max(profit[idx[i]],dp[idx[i-1]]) return max(dp)
leetcode-159周赛-5233-规划兼职工作*的更多相关文章
- 【js】Leetcode每日一题-完成所有工作的最短时间
[js]Leetcode每日一题-完成所有工作的最短时间 [题目描述] 给你一个整数数组 jobs ,其中 jobs[i] 是完成第 i 项工作要花费的时间. 请你将这些工作分配给 k 位工人.所有工 ...
- [LeetCode] 159. Longest Substring with At Most Two Distinct Characters 最多有两个不同字符的最长子串
Given a string s , find the length of the longest substring t that contains at most 2 distinct char ...
- 【LeetCode】1466. 重新规划路线 Reorder Routes to Make All Paths Lead to the City Zero (Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 DFS BFS 日期 题目地址:https://lee ...
- leetcode 双周赛9 进击的骑士
一个坐标可以从 -infinity 延伸到 +infinity 的 无限大的 棋盘上,你的 骑士 驻扎在坐标为 [0, 0] 的方格里. 骑士的走法和中国象棋中的马相似,走 “日” 字:即先向左(或右 ...
- LeetCode双周赛#36
1604. 警告一小时内使用相同员工卡大于等于三次的人 题目链接 题意 给定两个字符串数组keyName和keyTime,分别表示名字为keytime[i]的人,在某一天内使用员工卡的时间(格式为24 ...
- ✡ leetcode 159. Longest Substring with At Most Two Distinct Characters 求两个字母组成的最大子串长度 --------- java
Given a string, find the length of the longest substring T that contains at most 2 distinct characte ...
- 第三个Sprint完结工作 用场景来规划测试工作.
一.根据用户使用场景测试: 1.流程 典型群体 群体 张小明 年龄 7-12岁 职业 小学生 收入 压岁钱还有零花钱 能力 看一些简单的数,做一些相对简单的事 爱好 玩游戏 典型场景 张小明平时喜欢玩 ...
- [LeetCode#159] Missing Ranges Strobogrammatic Number
Problem: Given a string, find the length of the longest substring T that contains at most 2 distinct ...
- leetcode[159] Longest Substring with At Most Two Distinct Characters
找到最多含有两个不同字符的子串的最长长度.例如:eoeabc,最长的是eoe为3,其他都为2. 思路: 用p1,p2表示两种字符串的最后一个出现的下标位置.初始p1为0. p2为-1.start初始化 ...
随机推荐
- 深入理解java虚拟机JVM(下)
深入理解java虚拟机JVM(下) 链接:https://pan.baidu.com/s/1c6pZjLeMQqc9t-OXvUM66w 提取码:uwak 复制这段内容后打开百度网盘手机App,操作更 ...
- 怎么部署TFS
https://vsalm-hols.readthedocs.io/zh_CN/latest/sysadmin/tfs-installation-ad.html 根据以上网站的步骤一字不差的进行部署肯 ...
- ES6 数组扩展(总结)
1.扩展运算符 将一个数组转为用逗号分隔的参数序列 console.log(1, ...[2, 3, 4], 5) // 1 2 3 4 5 2.Array.from() 将两类对象转为真正的数组 类 ...
- springboot集成使用rabbitmq笔记(1.rabbitmq安装)
使用rabbitmq笔记一 使用rabbitmq笔记二 使用rabbitmq笔记三 1.选择适配的版本,参考---https://www.rabbitmq.com/which-erlang.html ...
- Mysql学习笔记(004)- 条件查询
条件查询 #进阶2:条件查询 /* 语法: select 查询列表③ from 表名① where 条件筛选② 分类: 一.按条件表达式筛选 条件运算符:> < = != <> ...
- Delphi DBgrid 动态点击事件
错误的写法: DBGrid1CellClick(DBGrid1.Columns[ DBGrid1.DataSource.DataSet.RecNo ]); //执行点击事件 正确的写法: DBGrid ...
- Vue学习笔记【9】——Vue指令之v-for和key属性
迭代数组(普通数组.对象数组) <ul> <li v-for="(item, i) in list">索引:{{i}} --- 姓名:{{item.name ...
- 【LeetCode 8】字符串转换整数 (atoi)
题目链接 [题解] 注意越界的处理就好 简单题 还有.. 正的-2^31不能由2^31取相反数得到,因为正的int最多到2^31-1 [代码] class Solution { public: boo ...
- Android中如何做到自定义的广播只能有指定的app接收
今天没吊事,又去面试了,具体哪家公司就不说了,因为我在之前的blog中注明了那些家公司的名字,结果人家给我私信说我泄露他们的题目,好吧,我错了...其实当我们已经在工作的时候,我们可以在空闲的时间去面 ...
- renren-fast-vue-动态路由
在renren-fast-vue项目中,左侧边栏的系统管理这一模块的路由采用的是动态路由的写法, 模块中的路由内容由后台动态生成,在前端开发阶段,采用的是mock模拟数据生成 先是在左侧边栏(view ...