Maximize Profile Impact
On LinkedIn, professionals strategically curate their profiles to showcase their most impactful achievements. Often, there's a practical limit to how much detail can be provided or how many projects can be highlighted effectively, representing a 'time budget' a recruiter or peer might spend reviewing. This problem simulates a scenario where a user needs to select a set of projects to feature on their profile, each with a specific timeCost (e.g., effort to prepare, space on profile) and an impactScore (e.g., perceived value, relevance). The goal is to maximize the total impact within a given timeBudget.
Implement a function maximizeProfileImpact that, given a list of projects and a total timeBudget, calculates the maximum possible total impactScore that can be achieved without exceeding the timeBudget.
timeBudget that is too small for any project.Function Signature:
interface Project {
timeCost: number;
impactScore: number;
}
function maximizeProfileImpact(projects: Project[], timeBudget: number): number;
Parameters:
projects: An array of Project objects. Each Project object has two properties:
timeCost: A non-negative integer representing the time commitment or resource cost for the project.impactScore: A non-negative integer representing the value or impact gained from including the project.timeBudget: A non-negative integer representing the maximum total timeCost that can be allocated across selected projects.Returns:
impactScore that can be achieved within the timeBudget.timeBudget (e.g., all projects have timeCost greater than timeBudget), the function should return 0.projects array are distinct entities; you cannot select the same project multiple times, even if it has identical timeCost and impactScore to another project in the list.Examples
Example 1
Input:
projects = [{ "timeCost": 10, "impactScore": 60 }, { "timeCost": 20, "impactScore": 100 }, { "timeCost": 30, "impactScore": 120 }], timeBudget = 50
Output:
220
Note:
Projects available: P1 (10, 60), P2 (20, 100), P3 (30, 120). Budget = 50.
The maximum achievable impact score is 220.
Example 2
Input:
projects = [{ "timeCost": 5, "impactScore": 10 }, { "timeCost": 4, "impactScore": 40 }, { "timeCost": 6, "impactScore": 30 }, { "timeCost": 3, "impactScore": 50 }], timeBudget = 10
Output:
90
Note:
Projects available: P1 (5, 10), P2 (4, 40), P3 (6, 30), P4 (3, 50). Budget = 10.
Example 3
Input:
projects = [{ "timeCost": 60, "impactScore": 100 }], timeBudget = 50
Output:
0
Note:
The only project available has a timeCost of 60, which exceeds the timeBudget of 50. No projects can be selected, resulting in a total impactScore of 0.
Constraints
1 <= projects.length <= 1000 <= timeBudget <= 50001 <= projects[i].timeCost <= 5001 <= projects[i].impactScore <= 1000timeCost and impactScore values are integers.projects.length and W is timeBudget.Loading editor...