Alice frequently takes exams and wants to track her scores and calculate the total scores over specific time periods.
Implement the ExamTracker class:
ExamTracker(): Initializes the ExamTracker object.void record(int time, int score): Alice takes a new exam at time time and achieves the score score.long long totalScore(int startTime, int endTime): Returns an integer that represents the total score of all exams taken by Alice between startTime and endTime (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,
record() will be made with strictly increasing time.record() is called with time = t, then totalScore() will always be called with startTime <= endTime <= t.
Example 1:
Input:
["ExamTracker", "record", "totalScore", "record", "totalScore", "totalScore", "totalScore", "totalScore"]
[[], [1, 98], [1, 1], [5, 99], [1, 3], [1, 5], [3, 4], [2, 5]]
Output:
[null, null, 98, null, 98, 197, 0, 99]
Explanation
ExamTracker examTracker = new ExamTracker();98 + 99 = 197.
Constraints:
1 <= time <= 1091 <= score <= 1091 <= startTime <= endTime <= t, where t is the value of time from the most recent call of record().record() will be made with strictly increasing time.ExamTracker(), the first function call will always be record().105 calls will be made in total to record() and totalScore().