Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!