Skip to the code
cf.
+25 XP

#525 Count the Longest Rising Sequences

medium

A metrics panel highlights the longest strictly rising sequences in a list of readings nums, where a sequence keeps the original order but may skip readings. Two sequences are different if they use a different set of positions, even when the values are the same.

Write countLongestRises(nums) that returns how many strictly increasing subsequences have the maximum possible length, modulo 1000000007.

Example 1

Input: nums = [1,3,2,4]
Output: 2

The longest length is 3, reached by 1, 3, 4 and by 1, 2, 4.

Example 2

Input: nums = [3,3,3]
Output: 3

The longest length is 1, and each of the three positions is one such sequence.

Constraints

  • 1 <= nums.length <= 2000
  • -10^6 <= nums[i] <= 10^6
Saved in this browser

Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.

Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).