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

歡迎光臨散文網(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)遵守國家法律
贵南县| 望谟县| 田阳县| 柳林县| 龙川县| 阜宁县| 五指山市| 中阳县| 毕节市| 陆河县| 柳江县| 深圳市| 尉犁县| 满城县| 普定县| 盐边县| 象州县| 巫溪县| 霞浦县| 泰安市| 慈利县| 滁州市| 山阴县| 淅川县| 山丹县| 平江县| 郑州市| 渭南市| 太白县| 汾西县| 黑龙江省| 剑川县| 长宁县| 璧山县| 阿克陶县| 光山县| 元氏县| 富蕴县| 昌邑市| 大渡口区| 资中县|