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

138
Visualizações
Finding similar values in multiple arrays of objects

Data:

array1 = [{"location": "The Green Lion", "postcode": "E1 6QE"}, {"location": "Diners Inn", "postcode": "E6 5FD"}]
array2 = [{"location": "Green Lion", "postcode": "E1 6QE"}, {"location": "Diner's Inn", "postcode": "E6 5FD"}]
array3 = [{"location": "The Green Lion", "postcode": "E1 6QE"}, {"location": "Diner Inn", "postcode": "E6 5FD"}]
//array1 size - 350 | array2 size - 544 | array3 size - 88

I'm using a fuzzy comparison function to find similar elements in an array. The issue I'm facing is that my current way of achieving this involves combining the 3 arrays into 1 and for looping it twice and then fuzzy comparing location.

combined.forEach(function (x) {
        combined.forEach(function (y) {
            if (fuzz.token_sort_ratio(x.location, y.location) > 80) {
                //Logic 
            }
        });
    });

Is there a more efficient way of achieving this instead of a nested for loop? The combined array size is 958 which means there are 917,764 iterations being ran, this doesn't seem like an efficient way of achieving this but because the value of location isn't always guaranteed to be the same, I can't use the .find() function (or can I?).

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I'd recommend to create map of the locations and store results in the quadtree. Quadtree is supported by JavaScript - see

https://github.com/timohausmann/quadtree-js

I've used successfully quadtree in my practice (implemented in C++). For large datasets it appeared to be at least 10X faster than quadratic algorithm.

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