Advertisement
Guest User

Untitled

a guest
Oct 4th, 2023
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. let input = [[2, 4],[1, 2, 3, 4],];
  2.  
  3. let print = this.print || console.log;
  4. let gets =this.gets ||((arr, index) => () =>arr[index++])(input, 0);
  5.  
  6. let firstArray = gets()//.split(",").map(Number);
  7. let secondArray = gets()//.split(",").map(Number);
  8. let newArray = [];
  9.  
  10. for (let i = 0; i < firstArray.length; i++) {
  11. let ind = secondArray.indexOf(firstArray[i]);
  12.  
  13. for (let j = ind; j < secondArray.length; j++) {
  14. if (secondArray[j] > firstArray[i]) {
  15. newArray.push(secondArray[j]);
  16. break;
  17. } else if (j + 1 === secondArray.length) {
  18. newArray.push(-1);
  19. }
  20. }
  21. }
  22. console.log(newArray.join(","));
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement