Advertisement
Guest User

ex arr 05

a guest
Jan 24th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(arr) {
  2.     let newArr = [];
  3.     let first = arr.shift();
  4.     newArr.push(first);
  5.     while(arr.length !== 0) {
  6.         let[cur, next] = [newArr[newArr.length - 1], arr.shift()];
  7.         if (next > cur) newArr.push(next);
  8.     }
  9.     newArr.forEach(i => console.log(i));
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement