dabidabidesh

Untitled

Jun 16th, 2020
348
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function nonDecreasingSubsequence0(arr) {
  2.   console.log(arr.filter((el, index) => el >= Math.max(...arr.slice(0, index))).join(' '))
  3. }
  4.  
  5. nonDecreasingSubsequence1 = arr => {
  6.   'use strict'
  7.  
  8.   let max = arr[0]
  9.   let result = arr.filter(el => {
  10.     if (el >= max) max = el
  11.  
  12.     return el >= max
  13.   })
  14.  
  15.   console.log(result.join(' '))
  16. }
RAW Paste Data