nikolayneykov

Untitled

Feb 9th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function extractSubsequence(arr) {
  2.     let result = [];
  3.     result.push(arr.shift());
  4.     while (arr.length > 0) {
  5.         if (result[result.length - 1] <= arr[0]) {
  6.             result.push(arr.shift());
  7.         } else {
  8.             arr.shift();
  9.         }
  10.     }
  11.     return result.join(' ');
  12. }
Advertisement
Add Comment
Please, Sign In to add comment