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