Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function nonDecreasingSubsequence0(arr) {
- console.log(arr.filter((el, index) => el >= Math.max(...arr.slice(0, index))).join(' '))
- }
- nonDecreasingSubsequence1 = arr => {
- 'use strict'
- let max = arr[0]
- let result = arr.filter(el => {
- if (el >= max) max = el
- return el >= max
- })
- console.log(result.join(' '))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement