Skip to content

Instantly share code, notes, and snippets.

@vitalii-komenda
Created June 5, 2021 10:50
Show Gist options
  • Save vitalii-komenda/590882d5e508861a78e16f852bacacbf to your computer and use it in GitHub Desktop.
Save vitalii-komenda/590882d5e508861a78e16f852bacacbf to your computer and use it in GitHub Desktop.
arr = [5, 2, 8, 6, 3, 6, 5, 5];
longestContinuesSubseq = (a) => {
let t = Array(a.length).fill(1);
for(let i=1; i<t.length; i++) {
let smalerUntilI = [];
for(let j=0; j<i; j++) {
if (a[j] < a[i]) {
smalerUntilI.push(t[j]);
}
}
t[i] = 1 + Math.max(...smalerUntilI);
}
return Math.max(...t);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment