bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
EasySliding WindowLC 1176

Diet Plan Performance

A dieter consumes calories[i] calories on the i\-th day. Given an integer k, for every consecutive sequence of k days (calories[i], calories[i+1], ..., calories[i+k-1] for all 0 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.

Asked at 1 company
Amazon
Hints
  • 1.Think about which data structure fits best
  • 2.Consider the time complexity of your approach
  • 3.Look for patterns in the constraints
LeetCode