Number of Longest Increasing Subsequences

medium · dp, lis

Number of Longest Increasing Subsequences

Given an array nums, return the number of longest strictly increasing subsequences.

Function signature

func CountLIS(nums []int) int

Example

nums = [1,3,5,4,7]
output = 2

Constraints

  • 0 <= len(nums) <= 2_000
  • -1_000_000_000 <= nums[i] <= 1_000_000_000

Notes

  • Use DP with length and count arrays.
Run tests to see results
No issues detected