当前位置:网站首页>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;
}
}
边栏推荐
- PostgreSQL使用Pgpool-II实现读写分离+负载均衡
- 快讯 l Huobi Ventures与Genesis公链深入接洽中
- Hydrogen future industry accelerates | the registration channel of 2022 hydrogen energy specialty special new entrepreneurship competition is opened!
- DAY ONE
- okcc呼叫中心的订单管理时怎么样的
- SuperSocket 1.6 创建一个简易的报文长度在头部的Socket服务器
- Compile logisim
- A way of writing SQL, update when matching, or insert
- AVL树到底是什么?
- Personal digestion of DDD
猜你喜欢
Rider离线使用Nuget包的方法
Zero code and high return. How to use 40 sets of templates to meet 95% of the reporting needs in the work
After leaving a foreign company, I know what respect and compliance are
DAY FIVE
Close unregistering application XXX with Eureka with status down after Eureka client starts
Design a red envelope grabbing system
Why is bat still addicted to 996 when the four-day working system is being tried out in Britain?
Tourism Management System Based on jsp+servlet+mysql framework [source code + database + report]
iMeta | 华南农大陈程杰/夏瑞等发布TBtools构造Circos图的简单方法
Pytest multi process / multi thread execution test case
随机推荐
Matplotlib draws a histogram and adds values to the graph
The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance
Google, Baidu and Yahoo are general search engines developed by Chinese companies_ Baidu search engine URL
DAY FOUR
How to use vector_ How to use vector pointer
DAY TWO
How does win11 restore the traditional right-click menu? Win11 right click to change back to traditional mode
How to find out if the U disk file of the computer reinstallation system is hidden
MATLIB reads data from excel table and draws function image
Do you still have to rely on Simba to shout for a new business that is Kwai?
快讯 l Huobi Ventures与Genesis公链深入接洽中
Gradle knowledge generalization
Asset security issues or constraints on the development of the encryption industry, risk control + compliance has become the key to breaking the platform
【212】php发送post请求有哪三种方法
Introduction au GPIO
[212] what are three methods for PHP to send post requests
37页数字乡村振兴智慧农业整体规划建设方案
Imeta | Chen Chengjie / Xia Rui of South China Agricultural University released a simple method of constructing Circos map by tbtools
Three application characteristics of immersive projection in offline display
零代码高回报,如何用40套模板,能满足工作中95%的报表需求