FastPrepFastPrep
Problem Brief

Get Max Skill Sum

NEW GRADFULLTIMEOA
See Amazon online assessment and hiring insights

A manager at Amazon is managing a team of n employees with IDs numbered from 0 to n - 1. Some employees are marketing experts and others are developers. The employee with id i has a skill level of skill[i]. The employee is a marketing expert if expertise[i] is 0 and a developer if expertise[i] is 1.

The manager wants to select a team to work on a project with some contiguous set of ids [i, i + 1, i + 2, ..., j] such that there is an equal number of marketing experts and developers and the total sum of skills is maximized.

Given two arrays, skill and expertise, find the maximum possible sum of skills of any team that can be formed respecting the above conditions.

Note:

  • It is always possible to form a team consisting of zero employees with a total skill of zero.
  • A contiguous set of elements is a sequence where each element is adjacent to the next, with no gaps between them. Each element in the set is directly next to the previous one.
  • Function Description

    Complete the function getMaxSkillSum in the editor.

    getMaxSkillSum takes the following arguments:

    1. int expertise[n]: the expertise of the employees
    2. int skill[n]: the skill level of the employees

    Returns

    long: the maximum possible sum of skill levels of the team

    1Example 1

    Input
    expertise = [0, 0, 0, 1], skill = [10, 2, 3, 4]
    Output
    7
    Explanation
    Example 1 illustration
    The optimal selection is [3, 4] with 1 marketing expert and 1 developer. The sum of skills is 3 + 4 = 7. Hence the answer is 7.
    public long getMaxSkillSum(int[] expertise, int[] skill) {
      // write your code here
    }
    
    Input

    expertise

    [0, 0, 0, 1]

    skill

    [10, 2, 3, 4]

    Output

    7

    Sign in to submit your solution.