Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function extractNonDescreasingSubsequence(input) {
- let maxNumber = input[0]
- let output = [];
- output[0] = maxNumber;
- for (let i = 1; i < input.length; i++) {
- if (maxNumber <= input[i]) {
- maxNumber = input[i];
- output.push(maxNumber);
- }
- }
- console.log(output.join(' '));
- }
Advertisement
Add Comment
Please, Sign In to add comment