FunctionRacerProblemsRace

Step Goal Streaks

EasyClassesPython, JavaScript, TypeScript, Java, C++

Implement a class StepLog that records one step count per day and tracks streaks of days that reach a goal. A day meets the goal when its steps are at least goal. Write these methods:

The tests call the methods in sequence and compare every return value. The expected list holds null for the constructor.

Example 1

StepLog(5000)
log_day(6000) returns 1
log_day(5000) returns 2
log_day(7000) returns 3
get_best_streak() returns 3
fix_last(100) returns 0
get_best_streak() returns 2
log_day(8000) returns 1

Exactly 5000 steps meets the goal, so the first three days make a streak of 3. Fixing the third day to 100 breaks it, and the best streak drops to 2.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Classes problems