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

248
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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