A dieter consumes
calories[i]
calories on thei
-th day.Given an integer
k``k
days (calories[i], calories[i+1], ..., calories[i+k-1]
for all0 <= i <= n-k``k
days (calories[i] + calories[i+1] + ... + calories[i+k-1]
):
- 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.
Initially, the dieter has zero points. Return the total number of points the dieter has after dieting for
calories.length
days.Note that the total points can be negative.
1 | class Solution { |