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

213
Visualizações
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 à 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