Freelancing Platform
A customer has posted several web development projects on a freelancing platform, and various web developers have put in bids for these projects. Given the bid amounts and their corresponding projects, what is the minimum amount the customer can pay to have all projects completed?
Note: If any project has no bids, return -1.
Complete the function minCost in the editor.
minCost has the following parameters:
int numProjects: the total number of projects posted by the client (labeled from 0 to n-1)int project[n]: the projects that the freelancers bid onint bid[n]: the bid amounts posted by the freelancersReturns
long: the minimum cost the client can spend to complete all projects, or -1 if any project has no bids.
゚⋆ ゚🪐 Credit to chizzy_elect° ᡣ𐭩˚☽˚。⋆
1Example 1
2Example 2
Constraints
Limits and guarantees your solution can rely on.
- 1 ≤ numProjects, n ≤ 5 x 105
- 0 ≤ project[i] < n
- 1 ≤ bid[i] ≤ 109