SHARE
TWEET

ex arr 05

a guest Jan 24th, 2020 82 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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top