We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
function twoArrays(k, A, B) {
A = A.sort((a,b)=>a-b);
B = B.sort((a,b)=>b-a);
console.log('Inputs'+k, A,B);
for(let i=0; i < A.length; i++){
if(A[i] + B[i] < k){
return 'NO';
}
}
return 'YES';
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Permuting Two Arrays
You are viewing a single comment's thread. Return to all comments →
JS Code
function twoArrays(k, A, B) { A = A.sort((a,b)=>a-b); B = B.sort((a,b)=>b-a); console.log('Inputs'+k, A,B); for(let i=0; i < A.length; i++){ if(A[i] + B[i] < k){ return 'NO'; } } return 'YES';
}