Minimum Project Bid Cost
Updated
Problem statement
A customer has posted numProjects web development projects on a freelancing platform. The projects are numbered from 0 through numProjects - 1.
You are given two arrays, projectId and bid. For each index i, a developer offers to complete project projectId[i] for bid[i] currency units.
- Choose one bid for each project.
- Each bid can be chosen independently of the other bids.
Return the minimum total cost to complete all projects. If any project has no bids, return -1.
Function
minCost(numProjects: int, projectId: int[], bid: int[]) → longExamples
Example 1
numProjects = 3projectId = [2,0,1,2]bid = [8,7,6,9]return = 21The minimum bids for projects 0, 1, and 2 are 7, 6, and 8. Choose the first bid of 8 for project 2 instead of its later bid of 9. The total is 7 + 6 + 8 = 21.
Example 2
numProjects = 4projectId = [2,0,1,2]bid = [8,7,6,9]return = -1Project 3 has no bids, so all four projects cannot be completed. Return -1.
Example 3
numProjects = 2projectId = [0,1,0,1]bid = [5,0,0,9]return = 0Both projects have a bid of 0. Choose those two bids for a total cost of 0.
Example 4
numProjects = 2projectId = [0,1,0,1,1]bid = [4,74,47,744,7]return = 11Project 0 has bids 4 and 47, so its minimum is 4. Project 1 has bids 74, 744, and 7, so its minimum is 7. The total is 4 + 7 = 11.
Constraints
1 <= numProjects <= 5 * 10^5.1 <= projectId.length = bid.length <= 5 * 10^5.0 <= projectId[i] < numProjectsfor every bid.0 <= bid[i] <= 10^9for every bid.- The result fits in a signed 64-bit integer.
More Adobe Online Assessment questions
- Base Unit ConversionsOA · Seen Nov 2026
- Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
- Top-Funded Villages and ProjectsOA · Seen Aug 2026
- Count Parent Nodes With a Target SumOA · Seen Aug 2026
- Largest Binary Number by ConcatenationOA · Seen Aug 2026
- Count Events by CategoryOA · Seen Aug 2026
- Graph M-ColoringOA · Seen Aug 2026
- Hall of Shifting TilesOA · Seen Aug 2026
- K-th Ancestor Subtree Preorder QueryOA · Seen Aug 2026
- Maze ReachabilityOA · Seen Aug 2026
Similar questions at other companies
- Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Server InvestmentRippling · OARippling interview questions
- Book Reading EveningsGoogle · OAGoogle interview questions
- Maximum Apples That Fit in a BoxVirtu Financial · OAVirtu Financial interview questions
- Minimum Project Bid CostNVIDIA · OANVIDIA interview questions
- Minimum AmountBelvedere Trading · OA
- Maximum Income from Asset TradingJefferies · OA
- Maximum Three-Server Difficulty ScoreVisa · OAVisa interview questions
- Economical TripAccenture · OAAccenture interview questions
- Best Time to Buy and Sell StockFlexTrade · OAFlexTrade interview questions
Adobe interview experiences
- Adobe New Grad OA: Unit Conversion and Code Review: 1 Experience
- Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
- Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
- Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
- Adobe New Grad MTS Interview Questions: 7 Experiences
- Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)