Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

241
Visualizações
Interview Question: How to calculate if given a maximum CPU, will the job be true or false overtime?

I have recently received this interview question and got stuck: How to calculate if given a maximum CPU, will the job be true or false over time??

Let's say if we have a Job class with a constructor with startTime, duration, and cups for this specific job. We need to create a function with a given maxCpus, and see if the jobs will either be possible for the CPU requirement or not, return true or false.

Below is some example of the true and false cases.

Example: maxCpus = 3
0123456789
0---(3) 0--------(2)
  0------------(1) => false

Example: maxCpus = 3
0---3 0--------2 0-------1 => true

Example:
0 1 2 3 4 5 6 7 8 9
    0 - - - (start: 2, duration: 4)
      0 - - (start: 3, duration: 3)

earliest start ---------------- latest end time
jobs = [{startTime: 1, duration: 2, cpus: 5}, {}];
       [{}, {}, {}]

Below is some of the code I wrote for this question, but be aware that my solution is not correct!!!

function checkSchedule(maxCpus, jobs){
 let check;
 for (job in jobs) {
   const earliestStart = Math.min(...Object.values(job.startTime))
   const latestEnd = Math.max(job.startTime + (job.duration - 1))
   let endPoint = job.startTime + (job.duration - 1);
 }
 if(maxCpus <= ){
   check = true
 } else {
   check = false
 }
 return check;
}

I am still not able to figure out the solution to this question.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda