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

186
Views
Cadena sin caracteres repetidos

Tengo r = cuántas veces se puede repetir la letra en una fila y s = a la cadena para verificar.
Por ejemplo si s = "aaabbbccc777" y r = 2. resultado = "aabbcc77".
Necesito que sea dinámico y lo más fácil y limpio posible.

Gracias por la ayuda por adelantado.

 let s = "bbbaaaccc777cdggg"; let r = 2; const verification = (s, r) => { } verification(s, r);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede iterar sobre la cadena de esta manera:

 const verification = (s, r) => { let res = '', last = null, counter = 0; s.split('').forEach(char => { if (char == last) counter++; else { counter = 0; last = char; } if (counter < r) res += char; }); return res; }
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!