Find Max Health Sum
Amazon is building a new data center with n servers of different types. The health and type of each server are represented in the arrays health and serverType. The developers need to build a server facility with a maximum of m distinct types of servers and the sum of their health should be maximized.
Given arrays health and serverType, find the maximum sum of the health for up to m types of servers.
Complete the function findMaxHealthSum in the editor below.
findMaxHealthSum has the following parameters:
- 1.
int health[n]: the health of each server - 2.
int serverType[n]: the type of each server - 3.
m: the maximum number of distinct types
Returns
long int: the maximum sum of health of the selected servers
1Example 1

m = 1, all selected servers must be the same type. The better option is to select type 2 servers. Return 11.Constraints
Limits and guarantees your solution can rely on.
1 ≤ m ≤ n ≤ 10^51 ≤ health[i] ≤ 10^91 ≤ serverType[i] ≤ n