当前位置:网站首页>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;
}
}
边栏推荐
- Yaduo Sangu IPO
- C语言输入/输出流和文件操作【二】
- After leaving a foreign company, I know what respect and compliance are
- Penetration test --- database security: detailed explanation of SQL injection into database principle
- 17、 MySQL - high availability + read / write separation + gtid + semi synchronous master-slave replication cluster
- Wechat applet UploadFile server, wechat applet wx Uploadfile[easy to understand]
- There are only two TXT cells in the ArrayExpress database. Can you only download the sequencing run matrix from line to ENA?
- MIT 6.824 - raft Student Guide
- [CVPR 2022] semi supervised object detection: dense learning based semi supervised object detection
- app通用功能测试用例
猜你喜欢
快手的新生意,还得靠辛巴吆喝?
Gradle knowledge generalization
How can computers ensure data security in the quantum era? The United States announced four alternative encryption algorithms
DAY SIX
Close unregistering application XXX with Eureka with status down after Eureka client starts
Rider离线使用Nuget包的方法
AVL树到底是什么?
Interface joint debugging test script optimization v4.0
The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance
互动滑轨屏演示能为企业展厅带来什么
随机推荐
What is a responsive object? How to create a responsive object?
GPIO简介
Random类的那些事
从外企离开,我才知道什么叫尊重跟合规…
The largest single investment in the history of Dachen was IPO today
Unity color palette | color palette | stepless color change function
Imeta | Chen Chengjie / Xia Rui of South China Agricultural University released a simple method of constructing Circos map by tbtools
What is AVL tree?
MATLIB reads data from excel table and draws function image
TypeScript中使用类型别名
Geo data mining (III) enrichment analysis of go and KEGG using David database
Pytest multi process / multi thread execution test case
PostgreSQL高可用之repmgr(1主2从+1witness)+Pgpool-II实现主从切换+读写分离
2022年PMP项目管理考试敏捷知识点(9)
Gradle knowledge generalization
Design of short chain
【212】php发送post请求有哪三种方法
What is web penetration testing_ Infiltration practice
Wechat applet UploadFile server, wechat applet wx Uploadfile[easy to understand]
互动滑轨屏演示能为企业展厅带来什么