Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function extractSubsequence(arr) {
- let result = [];
- result.push(arr.shift());
- while (arr.length > 0) {
- if (result[result.length - 1] <= arr[0]) {
- result.push(arr.shift());
- } else {
- arr.shift();
- }
- }
- return result.join(' ');
- }
Advertisement
Add Comment
Please, Sign In to add comment