1
var findNumberOfLIS = function (nums) {2
const { length } = nums;3
const dpLength = Array(length).fill(1);4
const dpCount = Array(length).fill(1);6
for (let right = 0; right < length; right++) {7
for (let left = 0; left < right; left++) {8
if (nums[left] >= nums[right]) continue;9
if (dpLength[left] + 1 === dpLength[right]) {10
dpCount[right] += dpCount[left];11
} else if (dpLength[left] + 1 > dpLength[right]) {12
dpLength[right] = dpLength[left] + 1;13
dpCount[right] = dpCount[left];18
const maxLength = Math.max(...dpLength);19
return dpLength.reduce((result, length, index) => {20
const count = dpCount[index];21
return result + (maxLength === length ? count : 0);