当前位置:网站首页>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;
}
}
边栏推荐
- Interface joint debugging test script optimization v4.0
- MIT 6.824 - raft Student Guide
- PostgreSQL使用Pgpool-II实现读写分离+负载均衡
- 使用源码编译来安装PostgreSQL13.3数据库
- 陀螺仪的工作原理
- Every year, 200 billion yuan is invested in the chip field, and "China chip" venture capital is booming
- js导入excel&导出excel
- 【CVPR 2022】半监督目标检测:Dense Learning based Semi-Supervised Object Detection
- Use Yum or up2date to install the postgresql13.3 database
- kubernetes部署ldap
猜你喜欢

MATLIB从excel表中读取数据并画出函数图像

Three application characteristics of immersive projection in offline display

DAY FIVE

DAY FIVE

Introduction au GPIO

DAY THREE

What is a responsive object? How to create a responsive object?

Imeta | Chen Chengjie / Xia Rui of South China Agricultural University released a simple method of constructing Circos map by tbtools

Geo data mining (III) enrichment analysis of go and KEGG using David database

The largest single investment in the history of Dachen was IPO today
随机推荐
[CVPR 2022] semi supervised object detection: dense learning based semi supervised object detection
Designed for decision tree, the National University of Singapore and Tsinghua University jointly proposed a fast and safe federal learning system
Quickly use various versions of PostgreSQL database in docker
量子时代计算机怎么保证数据安全?美国公布四项备选加密算法
Imeta | Chen Chengjie / Xia Rui of South China Agricultural University released a simple method of constructing Circos map by tbtools
沉浸式投影在线下展示中的三大应用特点
Oracle中使用包FY_Recover_Data.pck来恢复truncate误操作的表
MATLIB从excel表中读取数据并画出函数图像
Local deployment Zeppelin 0.10.1
Three sentences to briefly introduce subnet mask
2022年PMP项目管理考试敏捷知识点(9)
[automated testing framework] what you need to know about unittest
谷歌百度雅虎都是中国公司开发的通用搜索引擎_百度搜索引擎url
A way of writing SQL, update when matching, or insert
TypeScript中使用类型别名
The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance
Liuyongxin report | microbiome data analysis and science communication (7:30 p.m.)
三句话简要介绍子网掩码
零代码高回报,如何用40套模板,能满足工作中95%的报表需求
PostgreSQL uses pgpool II to realize read-write separation + load balancing