function liss(arr) { console.log('Array', arr); let n = arr.length; let liss = new Array(n); liss[n-1] = 1; let cliss; for (let i = n-2; i >= 0; i--) { cliss = 1; for (let j = i+1; j < n; j++) { if (arr[i] < arr[j]) { cliss = Math.max(cliss, 1+liss[j]); } } liss[i] = cliss; console.log(`LISS(${i}) == ${liss[i]}`); } return cliss[0]; } console.log(`LISS ${liss([1,2,4,3])}`);