当前位置:网站首页>Leecode brushes questions to record interview questions 17.16 massagist
Leecode brushes questions to record interview questions 17.16 massagist
2022-07-07 00:12:00 【Why is there a bug list】
topic
A famous masseuse will receive a steady stream of appointment requests , Every appointment can be accepted or not . There should be a break between appointments , So she can't accept the next appointment . Given an appointment request sequence , Find the best set of appointments for the masseuse ( The longest total appointment time ), Return the total minutes .
Be careful : This question is slightly changed from the original one
Example 1:
Input : [1,2,3,1]
Output : 4
explain : choice 1 No. and 3 Booking No , Total duration = 1 + 3 = 4.
Example 2:
Input : [2,7,9,3,1]
Output : 12
explain : choice 1 Booking No 、 3 No. and 5 Booking No , Total duration = 2 + 9 + 1 = 12.
Example 3:
Input : [2,1,4,5,3,1,1,3]
Output : 12
explain : choice 1 Booking No 、 3 Booking No 、 5 No. and 8 Booking No , Total duration = 2 + 4 + 3 + 3 = 12.
answer
class Solution {
public int massage(int[] nums) {
int a = 0, b = 0;
for (int i = 0; i < nums.length; i++) {
int c = Math.max(b, a + nums[i]);
a = b;
b = c;
}
return b;
}
}
边栏推荐
- DAY SIX
- How rider uses nuget package offline
- 2022年PMP项目管理考试敏捷知识点(9)
- App general function test cases
- Eureka Client启动后就关闭 Unregistering application xxx with eureka with status DOWN
- PostgreSQL uses pgpool II to realize read-write separation + load balancing
- Pytest multi process / multi thread execution test case
- 华为mate8电池价格_华为mate8换电池后充电巨慢
- [2022 the finest in the whole network] how to test the interface test generally? Process and steps of interface test
- Use Yum or up2date to install the postgresql13.3 database
猜你喜欢
How can computers ensure data security in the quantum era? The United States announced four alternative encryption algorithms
DAY TWO
基于jsp+servlet+mysql框架的旅游管理系统【源码+数据库+报告】
2022/2/11 summary
Imeta | Chen Chengjie / Xia Rui of South China Agricultural University released a simple method of constructing Circos map by tbtools
AVL树到底是什么?
【精品】pinia 基于插件pinia-plugin-persist的 持久化
Penetration test --- database security: detailed explanation of SQL injection into database principle
DAY FIVE
matplotlib画柱状图并添加数值到图中
随机推荐
Newsletter L Huobi ventures is in-depth contact with genesis public chain
STM32通过串口进入和唤醒停止模式
How rider uses nuget package offline
【212】php发送post请求有哪三种方法
C语言输入/输出流和文件操作【二】
2022/2/12 summary
(leetcode) sum of two numbers
PostgreSQL uses pgpool II to realize read-write separation + load balancing
DAY THREE
Who said that new consumer brands collapsed? Someone behind me won
iMeta | 华南农大陈程杰/夏瑞等发布TBtools构造Circos图的简单方法
PDF文档签名指南
2022 PMP project management examination agile knowledge points (9)
matplotlib画柱状图并添加数值到图中
Use package FY in Oracle_ Recover_ Data. PCK to recover the table of truncate misoperation
Google, Baidu and Yahoo are general search engines developed by Chinese companies_ Baidu search engine URL
Pytest multi process / multi thread execution test case
Unity 颜色板|调色板|无级变色功能
Personal digestion of DDD
There are only two TXT cells in the ArrayExpress database. Can you only download the sequencing run matrix from line to ENA?