Advertisement
Pijomir

Non-Decreasing Subset // with .filter

Oct 3rd, 2023 (edited)
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(arr) {
  2.     let result = arr.filter((a, b) => a >= Math.max(...arr.slice(0, b)));
  3.  
  4.     console.log(result.join(' '));
  5. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement