Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(arr) {
- let newArr = [];
- let first = arr.shift();
- newArr.push(first);
- while(arr.length !== 0) {
- let[cur, next] = [newArr[newArr.length - 1], arr.shift()];
- if (next > cur) newArr.push(next);
- }
- newArr.forEach(i => console.log(i));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement