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

241
Views
cómo verificar si dos listas son iguales, hasta una permutación en caml

Hola a todos, soy principiante en caml y estaba tratando de responder la siguiente pregunta, pero no sé por dónde empezar: ¿alguien puede ayudarme a resolver esto?

Escriba una función: una lista -> una lista -> bool que verifique si dos listas son equivalentes hasta la permutación. Por ejemplo [2; 3; 4; 3] es equivalente a [3; 3; 4; 2] pero no equivalente a [2; 4; 3]. Entonces, ¿cómo podemos verificar si dos listas son iguales, hasta una permutación en caml?

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

0

Lo siento, no sé muy bien javascript o caml. Aquí está mi versión. Java es lo suficientemente alto y estoy seguro de que lo entenderá.
Así es como lo haría:

 boolean equals(Type A1[], Type A2[]) { int len1 = A1.length; // length of the first array int len2 = A2.length; // length of the second array // if the length are not equal if(len1 != len2){ return false; } /*sort algorithm of your choice */ sort(A1); // sort first array sort(A2); for(int i = 0; i < len1; i++){ if(A1[i] != A2[i]) // if there is at least one non equal element return false; } // everything is ok return true; }
about 4 years ago · Juan Pablo Isaza Report

0

Tiene múltiples opciones para comparar la matriz. Una manera fácil sería hacer una cuerda.

 let arr1 = [2, 3, 4, 3].sort() let arr2 = [3, 3, 4, 2].sort() let arr3 = [2, 4, 3].sort() if(JSON.stringify(arr1) === JSON.stringify(arr2)) { console.log('arr1 = arr2'); } if(JSON.stringify(arr1) !== JSON.stringify(arr3)) { console.log('arr1 != arr3'); }

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!