Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit243c381

Browse files
refactor 1176
1 parentec09b8a commit243c381

File tree

1 file changed

+0
-39
lines changed

1 file changed

+0
-39
lines changed

‎src/main/java/com/fishercoder/solutions/_1176.java

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,5 @@
11
packagecom.fishercoder.solutions;
22

3-
/**
4-
* 1176. Diet Plan Performance
5-
*
6-
* A dieter consumes calories[i] calories on the i-th day.
7-
* Given an integer k, for every consecutive sequence of k days (calories[i], calories[i+1], ..., calories[i+k-1]
8-
* for all 0 <= i <= n-k), they look at T, the total calories consumed during that sequence of k days (calories[i] + calories[i+1] + ... + calories[i+k-1]):
9-
* If T < lower, they performed poorly on their diet and lose 1 point;
10-
* If T > upper, they performed well on their diet and gain 1 point;
11-
* Otherwise, they performed normally and there is no change in points.
12-
* Initially, the dieter has zero points. Return the total number of points the dieter has after dieting for calories.length days.
13-
*
14-
* Note that the total points can be negative.
15-
*
16-
* Example 1:
17-
* Input: calories = [1,2,3,4,5], k = 1, lower = 3, upper = 3
18-
* Output: 0
19-
* Explanation: Since k = 1, we consider each element of the array separately and compare it to lower and upper.
20-
* calories[0] and calories[1] are less than lower so 2 points are lost.
21-
* calories[3] and calories[4] are greater than upper so 2 points are gained.
22-
*
23-
* Example 2:
24-
* Input: calories = [3,2], k = 2, lower = 0, upper = 1
25-
* Output: 1
26-
* Explanation: Since k = 2, we consider subarrays of length 2.
27-
* calories[0] + calories[1] > upper so 1 point is gained.
28-
*
29-
* Example 3:
30-
* Input: calories = [6,5,0,0], k = 2, lower = 1, upper = 5
31-
* Output: 0
32-
* Explanation:
33-
* calories[0] + calories[1] > upper so 1 point is gained.
34-
* lower <= calories[1] + calories[2] <= upper so no change in points.
35-
* calories[2] + calories[3] < lower so 1 point is lost.
36-
*
37-
* Constraints:
38-
* 1 <= k <= calories.length <= 10^5
39-
* 0 <= calories[i] <= 20000
40-
* 0 <= lower <= upper
41-
* */
423
publicclass_1176 {
434
publicstaticclassSolution1 {
445
publicintdietPlanPerformance(int[]calories,intk,intlower,intupper) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp