Advertisement
dabidabidesh

nonDecreasingSubsequence

Jun 16th, 2020
2,408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function nonDecreasingSubsequence(arr) {
  2.   let output = arr[0] + ' '
  3.   for (let i = 0; i < arr.length; i++)
  4.     if (arr[i + 1] >= arr[i])
  5.       output += arr[i + 1] + ' '
  6.   console.log(output)
  7. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement