FastPrepTrack Maximum and Current Rating

Track Maximum and Current Rating

ZipRecruiter logoZipRecruiter● EasyNEW GRADOA
Learn

Problem statement

Your rating starts at 1500. Apply every signed value in changes from left to right.

Return a two-element array containing:

  1. the maximum rating observed, including the initial rating; and
  2. 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.

More ZipRecruiter problems

See ZipRecruiter hiring insights
public int[] trackRatingExtremes(int[] changes) {
    // Write your code here.
}
changes[100,-200,350,100,-600]
expected[1850,1250]
Checking account…