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

198
Views
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
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!