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

247
Views
Find missing number from a given string in js where start and end both are provided

Here's a string with numbers from 1 - 21, it's missing one number and the string is then shuffled, you're expected to return an array of possible missing numbers.

let str = "2198765123416171890101112131415"

findNumber(1, 21, str) // => [ 12, 21 ]

You won't be able to tell if its 21 or 12, so its best to return all possible values in an array.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

function findNumber(start, stop, string){
    let missingNumber = [];
    for(let i = start; i <= stop; i++){
        if(string.indexOf(i.toString()) === -1){
            missingNumber.push(i);
        }
    }
    return missingNumber
}
console.log(findNumber(1, 28, "24252627281234567891011121314151617181920212223"))

From this code I can get number only from 1 to 10 ,when 1,2...comes again it can not give me right answer...

about 4 years ago · Juan Pablo Isaza Report
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!