SHARE
TWEET

extractIncreasingSubsequenceFromArray

a guest Jan 24th, 2020 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function extractIncreasingSubsequenceFromArray(arr) {
  2.     const result =[];
  3.     let maxElement=arr[0];
  4.     for (let i = 0; i < arr.length; i++) {
  5.         const element = arr[i];
  6.         if(element>=maxElement)
  7.         {
  8.             result.push(element);
  9.             maxElement=element;
  10.         }
  11.     }
  12.     console.log(result.join('\n'));
  13. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top