Track Maximum and Current Rating
Problem statement
Your rating starts at 1500. Apply every signed value in changes from left to right.
Return a two-element array containing:
- the maximum rating observed, including the initial rating; and
- the final rating after every change.
Function
trackRatingExtremes(changes: int[]) → int[]Examples
Example 1
changes = [100,-200,350,100,-600]return = [1850,1250]The ratings are 1500, 1600, 1400, 1750, 1850, 1250. The maximum is 1850 and the final rating is 1250.
Example 2
changes = []return = [1500,1500]With no changes, both the maximum and final ratings remain at the initial value.
Constraints
0 <= changes.length <= 100000-100000 <= changes[i] <= 100000- Every intermediate rating fits in a signed 32-bit integer.