Software Feature Prioritization
In agile software development, product managers often face the challenge of prioritizing features given limited resources. Each feature requires a certain amount of development effort (cost) and consumes system resources (size). The goal is to maximize the number of features delivered while staying within budget and system capacity.
You are tasked with implementing a function maximizeFeatures that helps a product manager determine the maximum number of features that can be implemented. You are given a list of features, each with an associated size and cost, along with a maxSize (total system resource capacity) and maxCost (total development budget).
maximizeFeatures(features, maxSize, maxCost)
features: Feature[] - An array of objects, where each object represents a feature and has the following properties:
size: number - The system resource consumption for this feature (e.g., memory, disk space).cost: number - The development effort/cost for this feature.maxSize: number - The maximum total system resource capacity available.maxCost: number - The maximum total development budget available.Returns: number - The maximum number of features that can be implemented within the given maxSize and maxCost constraints.
size and cost values for features, maxSize, and maxCost will be positive integers.0.Examples
Example 1
Input:
features = [{size: 2, cost: 3}, {size: 3, cost: 4}, {size: 4, cost: 5}], maxSize = 5, maxCost = 7
Output:
2
Note:
To maximize features, we can select {size: 2, cost: 3} and {size: 3, cost: 4}. Their total size is 5 (<= 5) and total cost is 7 (<= 7). This gives 2 features. No other combination yields more than 2 features within limits.
Example 2
Input:
features = [{size: 10, cost: 10}, {size: 20, cost: 20}], maxSize = 5, maxCost = 5
Output:
0
Note:
Neither feature can be selected individually as their size or cost exceeds the given maximums. Thus, 0 features can be implemented.
Example 3
Input:
features = [{size: 1, cost: 10}, {size: 2, cost: 1}, {size: 3, cost: 2}], maxSize = 3, maxCost = 12
Output:
2
Note:
Selecting {size: 1, cost: 10} and {size: 2, cost: 1} results in a total size of 3 (<= 3) and total cost of 11 (<= 12). This provides 2 features. Other combinations either exceed size/cost or yield fewer features.
Constraints
1 <= features.length <= 1001 <= feature.size <= 10001 <= feature.cost <= 10001 <= maxSize <= 100001 <= maxCost <= 10000Loading editor...