当前位置:网站首页>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;
}
}
边栏推荐
- Imeta | Chen Chengjie / Xia Rui of South China Agricultural University released a simple method of constructing Circos map by tbtools
- Use type aliases in typescript
- GPIO簡介
- Pdf document signature Guide
- PostgreSQL高可用之repmgr(1主2从+1witness)+Pgpool-II实现主从切换+读写分离
- 自动化测试工具Katalon(Web)测试操作说明
- Rider离线使用Nuget包的方法
- PostgreSQL highly available repmgr (1 master 2 slave +1witness) + pgpool II realizes master-slave switching + read-write separation
- Wind chime card issuing network source code latest version - commercially available
- TypeScript增量编译
猜你喜欢

DAY SIX

Server SMP, NUMA, MPP system learning notes.

2022/2/10 summary

The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance

Automatic test tool katalon (WEB) test operation instructions

Every year, 200 billion yuan is invested in the chip field, and "China chip" venture capital is booming

服务器SMP、NUMA、MPP体系学习笔记。

Rider离线使用Nuget包的方法

Devops can help reduce technology debt in ten ways

Penetration test --- database security: detailed explanation of SQL injection into database principle
随机推荐
MIT 6.824 - Raft学生指南
Things like random
1000字精选 —— 接口测试基础
How to find out if the U disk file of the computer reinstallation system is hidden
Why should a complete knapsack be traversed in sequence? Briefly explain
2022/2/11 summary
基于jsp+servlet+mysql框架的旅游管理系统【源码+数据库+报告】
TypeScript中使用类型别名
Random类的那些事
vector的使用方法_vector指针如何使用
Matplotlib draws a histogram and adds values to the graph
2022/2/10 summary
Basic chart interpretation of "Oriental selection" hot out of circle data
互动滑轨屏演示能为企业展厅带来什么
37页数字乡村振兴智慧农业整体规划建设方案
Design of short chain
Imeta | Chen Chengjie / Xia Rui of South China Agricultural University released a simple method of constructing Circos map by tbtools
iMeta | 华南农大陈程杰/夏瑞等发布TBtools构造Circos图的简单方法
Introduction au GPIO
Liuyongxin report | microbiome data analysis and science communication (7:30 p.m.)