最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

Leetcode1176 Diet Plan Performance

2023-01-02 16:39 作者:您是打尖兒還是住店呢  | 我要投稿

A dieter consumes calories[i] calories on the i-th day. For every consecutive sequence of k days, they look at T, the total calories consumed during that sequence of k days:

If T < lower, they performed poorly on their diet and lose 1 point; If T > upper, they performed well on their diet and gain 1 point; Otherwise, they performed normally and there is no change in points. Return the total number of points the dieter has after all calories.length days.

Note that: The total points could be negative.

Example 1:

Input: calories = [1,2,3,4,5], k = 1, lower = 3, upper = 3 Output: 0 Explaination: calories[0], calories[1] < lower and calories[3], calories[4] > upper, total points = 0.

Example 2:

Input: calories = [3,2], k = 2, lower = 0, upper = 1 Output: 1 Explaination: calories[0] + calories[1] > upper, total points = 1.

Example 3:

Input: calories = [6,5,0,0], k = 2, lower = 1, upper = 5 Output: 0 Explaination: calories[0] + calories[1] > upper, calories[2] + calories[3] < lower, total points = 0.

Constraints:

  1. 1 <= k <= calories.length <= 10^5

  • 0 <= calories[i] <= 20000

  • 0 <= lower <= upper

這次的題目是鎖著的,所以只能在GitHub上面找原題,測(cè)試案例只有2個(gè)了,,所以不知道跑數(shù)量級(jí)比較大的時(shí)候,會(huì)不會(huì)報(bào)錯(cuò)了。

數(shù)組也可以循環(huán),只是想用下ArrayList,先遍歷,每次根據(jù)K,求對(duì)應(yīng)的值,即可跑出來數(shù)據(jù)的。

Leetcode1176 Diet Plan Performance的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國家法律
彰化县| 修文县| 永城市| 印江| 高碑店市| 乌审旗| 柘荣县| 泰宁县| 肇东市| 高阳县| 屏东县| 普定县| 黄梅县| 西丰县| 城市| 阳山县| 遂川县| 土默特右旗| 治县。| 桐乡市| 拜城县| 吉安市| 临西县| 自治县| 黄浦区| 右玉县| 钟山县| 太仓市| 雅安市| 寿阳县| 炎陵县| 旅游| 东丽区| 随州市| 基隆市| 蒙城县| 澄迈县| 长岭县| 遂昌县| 资源县| 靖州|