length
and count
of size n
with all elements set to 1.i
from 0 to n - 1
.
i
, iterate with index j
from 0 to i - 1
.
nums[j] < nums[i]
, check if length[j] + 1 > length[i]
.
length[i]
to length[j] + 1
and set count[i]
to count[j]
.length[j] + 1 == length[i]
, add count[j]
to count[i]
.length
array, denote it as maxLength
.result
to 0.i
from 0 to n - 1
.
length[i] == maxLength
, add count[i]
to result
.result
.