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

117
Views
¿Cómo realizar un seguimiento de los rangos continuos y validar los nuevos antes de insertar una matriz de JavaScript?

tenemos algunos rangos de frecuencia en una matriz 2D. las matrices internas mantienen los límites superior e inferior de la frecuencia, y la matriz externa es una lista de rangos ordenados:

 /* [ [L0,U0], [L1,U1], [L2,U2] ] */ let freqList = [ [272.50,275.86], [279.18,283.34], [288.78,293.12] ]

los nuevos rangos no deben superponerse a los guardados, ¿cómo puedo validar los nuevos y llevarlos al índice de matriz exacto?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que solo necesita encontrar el primer índice de modo que su número más bajo sea mayor que su número más bajo. Asegúrate de que tu número mayor también sea menor que su número menor. Asegúrate de que el número mayor de los elementos anteriores sea menor que tu número menor. Luego córtalo en ese índice:

 let freqList = [ [272.50,275.86], [279.18,283.34], [288.78,293.12] ] const addRange = (min, max) => { if (min > max) { throw new Error('invalid') } // find the first element where the min element is greater than the current min // this could be a binary search if you need to care about performance const i = freqList.findIndex(el => el[0] >= min); if (i === -1) { freqList.push([min, max]); } if (max >= freqList[i][0] || (i !== 0 && min < freqList[i-1][1])) { throw new Error('invalid') } freqList.splice(i, 0, [min, max]); } addRange(100, 200) console.log('ok') try { addRange(0, 101); } catch(e) { console.log('invalid range caught') } try { addRange(199, 201); } catch(e) { console.log('invalid range caught') }

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!