Here a new problem!
Here the problem statement:
At Facebook, different tasks have to be executed simultaneously on a limited number of computers. You are given a set of incoming tasks. Each computer can execute at most one task, and each task must be fully executed on a single computer. You are given ints complexity and computers. Element i of complexity is the complexity of the i-th task. Element i of computers is the maximal complexity of a task that can be handled by the i-th computer. Return the maximal number of tasks that can be executed on the given computers.
Here my code:
public class ImportantTasks
public int maximalCost(int complexity, int computers)
int res = 0;
List<int> lista = new List<int>();
int tiempo = new int[computers.Length];
for (int i = 0; i < computers.Length; i++)
for (int i = 0; i < complexity.Length; i++)
int min = 10000000;
int n = -1;
for (int a = 0; a < lista.Count; a++)
tiempo[a] = lista[a] – complexity[i];
if (tiempo[a] >= 0 && tiempo[a] < min)
min = tiempo[a];
n = a;
if (n > -1)
Here an image with the solution passing all the system test:
If you have another approach, share with me in a comment!
Thank you very much