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

212
Vistas
codewars optimization of solution 4 kyu js

I can't done the huge numbers tests. Help me optimize my code. My solution:

    const dontGiveMeFive = (start, end) => {
  let res = []
  for (let i = start; i <= end; i++) {
    if (!i.toString().includes('5')) res.push(i)
  }
  return res.length
}

  dontGiveMeFive(40076, 215151422963990)
  dontGiveMeFive(-206981731, 223575697903165)
  dontGiveMeFive(-249022878360451, -249022878219653)   
  dontGiveMeFive(-90000000000000, 900000000000000)

Task: `This kata is the performance version of Don't give me five by user5036852.

Your mission, should you accept it, is to return the count of all integers in a given range which do not contain the digit 5 (in base 10 representation). You are given the start and the end of the integer range. The start and the end are both inclusive.

Examples:

1,9 -> 1,2,3,4,6,7,8,9 -> return 8 4,17 -> 4,6,7,8,9,10,11,12,13,14,16,17 -> return 12 The result may contain fives. ;-) The start will always be smaller than the end. Both numbers can be also negative.

The regions can be very large and there will be a large number of test cases. So brute force solutions will certainly time out! `

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