audipower

Non-Decreasing Subsequence

Jun 3rd, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(arr) {
  2.     let result = [];
  3.     let max = -Infinity;
  4.     arr.filter(e => {
  5.         if (e >= max) {
  6.             result.push(e);
  7.             max = e;
  8.         }
  9.     })
  10.     console.log(result.join(" "));
  11. }
Advertisement
Add Comment
Please, Sign In to add comment