954. Number of Longest Increasing Subsequences

HardTreesSegment TreeDynamic Programming

Given an integer array, return the number of longest strictly increasing subsequences. Two subsequences are different if they use different index sets. The input is a JSON array.

Input: A JSON array of integers.

Output: Integer — the count of longest increasing subsequences.

Examples

Example 1
Input: [1,3,5,4,7]
Output: 2
Explanation: Two LIS of length 4.
Example 2
Input: [2,2,2,2,2]
Output: 5
Explanation: Five LIS of length 1.
Example 3
Input: [1,2,3]
Output: 1
Explanation: One LIS.

Constraints

Asked by

AmazonGoogleMicrosoftMetaAdobe
Solve this problem in the editor →