Get Maximum Sum (a.k.a. Find Max Health Sum :P

Problem Overview

  • Select servers to maximize total health using at most k distinct server types (function getMaximumSum).
  • Input: health[n], serverType[n], k; Output: long int maximum health sum; Constraints: 1 ≤ k ≤ n ≤ 1e5, 1 ≤ health[i] ≤ 1e9, 1 ≤ serverType[i] ≤ n.
  • Context: Amazon data center planning with varied server types and health values.
  • From Amazon interviews; a coding interview problem and interview question on grouping and selection.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: