Algorithm · Amazon · Medium
You receive an integer array and must provide two operations: one raises every value in the array by 1, while the other retrieves the K greatest values after any number of such increments. Input: An integer array nums that stores the sequence; An integer K. Output: Provide these two methods through TopKIncremental(nums, k): updateNums(): Add 1 to each element of nums. getTopK(): Produce the K largest values currently in nums, arranged from greatest to least. Example:…
Checking your access…