0
I have two collections: A and B as List<int>
, both of the same size N.
In collection A, are the designs.
In B, the offerings by the project.
Illustrating:
projects[5, 1, 4, 5]
offers[8, 7, 6, 9]
Soon,
For the project 5, I have the offers: [8,9]
To the 1: [7]
To the 4: [6]
I would like to return as little value as possible between the offers for each project, following the example illustrated. That in case it will stay 8 + 7 + 6 = 21
Please someone could help me or refer me to another solution(links, references, etc)?
What I’ve done so far:
internal static long minCost(int numProjects, List<int> projectId, List<int> bid)
{
var projectsBids = new Dictionary<int, List<int>>();
int minValue = 0;
List<int> projects = projectId.Distinct().ToList();
if (projects.Count != numProjects)
{
return -1;
}
for (int i = 0; i < projects.Count; i++)
{
//Aqui eu preciso adicionar valores que estão para o projeto(projects[i]), mas não sei como
projectsBids.Add(projects[i], /*aqui*/);
}
return minValue;
}
Opa Eduardo. Thank you very much for the answer! I also thought of adding in a Dictonary<int, List<int>>, but I was left with a question of how to add the items in the lists for each key. The link between project and offers is only the I position of each collection, always the two collections have the same size. I thought the project interface 1 to 1-N offers.
– Álvaro Dantas
This is a hacker Hank exercise, which I had to do for an interview, but I couldn’t finish. I would like to resolve, for a next attempt.
– Álvaro Dantas
i added more details. Thanks again!
– Álvaro Dantas
I managed to solve :D! Vlw Eduardo, I used your query!
– Álvaro Dantas