Problem · Greedy

Least Hours to Implement Features

Learn this problem
MediumSalesforceOA
See Salesforce hiring insights

Problem statement

There are two lists of size n - developmentTime and integrationTime. Any feature can be either implemented by development or by integration. While development of multiple features can happen concurrently by multiple developers, integration of features can only be sequential and can only be done by the team lead. Return the least number of hours to implement all the n features. Assume, there are more than n developers.

Function

leastHours(developmentTime: int[], integrationTime: int[]) → int

Complete the function leastHours in the editor.

leastHours has the following parameters:

  1. 1. int[] developmentTime: an array of integers representing the time to develop each feature
  2. 2. int[] integrationTime: an array of integers representing the time to integrate each feature

Returns

int: the least number of hours to implement all features

Examples

Example 1

developmentTime = [3, 4, 5, 9]integrationTime = [3, 2, 5, 5]return = 5
First 3 features are developed and take 5 hours and in the meanwhile, integration of the last one takes place.

Example 2

developmentTime = [8, 10, 6, 7]integrationTime = [1, 2, 2, 1]return = 6
Sum of all integrations (1 + 2 + 2 + 1 = 6) is less than the minimum development time, so all features are integrated.

More Salesforce problems

drafts saved locally
public int leastHours(int[] developmentTime, int[] integrationTime) {
  // write your code here
}
developmentTime[3, 4, 5, 9]
integrationTime[3, 2, 5, 5]
expected5
checking account