Upskilling Candidates
Updated
Problem statement
Skills are numbered 1..n. You already own the skills in owned and must acquire every skill in required. Book i costs costs[i] and teaches all skills in books[i]. Choose books to minimize the total purchase cost. Each book can be bought at most once. Return -1 if the requirement cannot be met, or zero if you already meet it.
Repeated skill IDs in a list do not teach a skill more than once. Skills not required may be learned without penalty.
Function
upskillingCost(n: int, required: int[], owned: int[], costs: int[], books: int[][]) → intExamples
Example 1
n = 5required = [1,2,3,4]owned = [1,5]costs = [40,30,60]books = [[2,3,5],[4,4],[2,3,4]]return = 60The third book provides all three missing skills for 60, cheaper than buying the first two.
Example 2
n = 2required = [1,2]owned = [1]costs = [7]books = [[1]]return = -1Skill 2 cannot be obtained.
Constraints
- 1 <= n <= 15, 1 <= costs.length <= 100, and 1 <= costs[i] <= 100.
- All skill IDs are in [1,n], books.length equals costs.length, and each book teaches at least one skill. For this exercise, required and owned may be empty lists.
More Intuit Online Assessment questions
- Employee Promotion OpportunitiesOA · Seen Oct 2026
- Next Pascal Row CoefficientOA · Seen Oct 2026
- Parse Router LogsOA · Seen Oct 2026
- Longest Repeated Letter Block with Adjacent SwapsOA · Seen Oct 2026
- Maximum Square-Free DivisorOA · Seen Oct 2026
- Two Tribes from Taller-Person CountsOA · Seen Oct 2026
- Shortest Path from an Encoded GraphOA · Seen Sep 2026
- Oldest and Youngest EmployeesOA · Seen Sep 2026
- Pressure-Isolation Shutdown OrderOA · Seen Sep 2026
- Submask Sum QueriesOA · Seen Sep 2026
Similar questions at other companies
- Count Routes Through Four Shop TypesOpenAI · OAOpenAI interview questions
- Vehicle Builds for Required Terrain (Game Adaptation)Roblox · OARoblox interview questions
- Minimum Moves to Spread Stones Across a GridAmerican Express · OAAmerican Express interview questions
- Maximum Profit Under a Bitwise OR LimitConcentric AI · OAConcentric AI interview questions
- Bitwise XOR SubsequencesJP Morgan Chase · OAJP Morgan Chase interview questions
- Beautiful Number OrderingsDocuSign · OADocuSign interview questions
- Minimum Operations To Reduce To ZeroUber · OAUber interview questions
- Bitwise XOR SubsequencesGoldman Sachs · OAGoldman Sachs interview questions
- Delete K Subsets for Maximum ScoreRubrik · OARubrik interview questions
- Optimize Discount Selection Under a Point BudgetPalantir · OAPalantir interview questions