highest no. in diagonal
function checkSolution(arr1, arr2) {
arr1.sort((a, b) => a - b); // Sorting arr1 in ascending order
arr2.sort((a, b) => a - b); // Sorting arr2 in ascending order
for (let i = 0; i < arr1.length; i++) {
if (arr1[i] > arr2[i]) {
return false;
}
}
return true;
}
// Test example 1
const arr1_1 = [7, 5, 3, 2];
const arr2_1 = [5, 4, 8, 7];
console.log(checkSolution(arr1_1, arr2_1)); // Output: true
// Test example 2
const arr1_2 = [1, 2, 4];
const arr2_2 = [1, 2, 3];
console.log(checkSolution(arr1_2, arr2_2)); // Output: false