Guest User

Untitled

a guest
May 19th, 2021
93
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let input = ['9 2 3 4 5 6 7 9 4 5 6 11 12 13 14 15 116 177 17'];
  2.  
  3. let print = this.print || console.log;
  4. let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
  5.  
  6. let arr = gets().split(' ').map(Number);
  7.  
  8. let maxSequence = [];
  9.  
  10. for (let i = 0; i < arr.length; i++) {
  11.     const currentSequence = [arr[i]];
  12.     //  print(currentSequence);
  13.     for (let j = i + 1; j < arr.length; j++) {
  14.         const lastAddedElement = currentSequence[currentSequence.length - 1];
  15.         if (lastAddedElement >= arr[j]) {
  16.             break;
  17.         }
  18.         currentSequence.push(arr[j]);
  19.     }
  20.     if (maxSequence.length <= currentSequence.length) {
  21.         maxSequence = currentSequence;
  22.     }
  23. }
  24. print(maxSequence.join(' '));
RAW Paste Data