Todorov_Stanimir

04. Non-Decreasing Subsequence Arrays - More Exercise

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