Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let firstArray = gets().split(',').map(Number);
- let secondArray = gets().split(',').map(Number);
- let resArr = [];
- for(let i = 0; i < firstArray.length; i++){
- let index = secondArray.indexOf(firstArray[i]);
- let result = -1;
- for(let j = index + 1; j < secondArray.length;j++){
- if(secondArray[j] > firstArray[i]){
- result = secondArray[j];
- break;
- }
- }
- resArr.push(result);
- }
- console.log(resArr.join(','));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement