Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

237
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda