3709. Design Exam Scores Tracker
Alice frequently takes exams and wants to track her scores and calculate the total scores over specific time periods.
Implement the
ExamTrackerclass:
ExamTracker(): Initializes theExamTrackerobject.void record(int time, int score): Alice takes a new exam at timetimeand achieves the scorescore.long long totalScore(int startTime, int endTime): Returns an integer that represents the total score of all exams taken by Alice betweenstartTimeandendTime(inclusive). If there are no recorded exams taken by Alice within the specified time interval, return 0.It is guaranteed that the function calls are made in chronological order. That is,
- Calls to
record()will be made with strictly increasingtime.- Alice will never ask for total scores that require information from the future. That is, if the latest
record()is called withtime = t, thentotalScore()will always be called withstartTime <= endTime <= t.
1 |
|