Advertisement
Spocoman

04. Non-Decreasing Subset

Jan 23rd, 2022
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.  
  3.     let print = [input[0]];
  4.     for (let i = 1; i <= input.length; i++){
  5.         if(print[print.length - 1] <= input[i]) {
  6.             print.push(input[i]);
  7.         }
  8.     }
  9.     console.log(print.join(" "));
  10.  
  11. }
  12.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement