1176. Diet Plan Performance
Description
**Input:** calories = [1,2,3,4,5], k = 1, lower = 3, upper = 3
**Output:** 0
**Explanation**: Since k = 1, we consider each element of the array separately and compare it to lower and upper.
calories[0] and calories[1] are less than lower so 2 points are lost.
calories[3] and calories[4] are greater than upper so 2 points are gained.**Input:** calories = [3,2], k = 2, lower = 0, upper = 1
**Output:** 1
**Explanation**: Since k = 2, we consider subarrays of length 2.
calories[0] + calories[1] > upper so 1 point is gained.ac
Last updated