Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

195
Vistas
Javascript - algorithm to sort 2d array

With 2d array like this

const initial2dArray = [['a','a','b'],['b','b','c']];

how can i create a function that removes consecutive similar elements in a row in each sub array and interchanges it with any other element in the other sub arrays repeatedly until no sub array in the 2d array contains two similar elements in a row. The output should be

const final2dArray = [['b','a','b'],['b','c','a']]

Or

[['b', 'a', 'b'], ['a', 'b', 'c']]

As far as no two elements appear more than once in a row

if the solution is available online please share link

note:

  1. The sub arrays can be any number and of varying length.
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda