Problem · Dynamic Programming
Count Bitonic Subsequences
Learn this problemProblem statement
Count non-empty subsequences that strictly increase to an interior peak and then strictly decrease. Both the increasing and decreasing parts must contain at least one step. Return the count modulo 10^9 + 7.
Function
countBitonicSubsequences(arr: int[]) → intExamples
Example 1
arr = [1,2,3,2,1]return = 11Eleven index-distinct subsequences have a strict rise followed by a strict fall.
Example 2
arr = [1,2,3,1]return = 4The valid subsequences are [1,2,1], [1,3,1], [2,3,1], and [1,2,3,1].
Constraints
1 <= arr.length <= 1000001 <= arr[i] <= 200
More Atlassian problems
- Planning ProductionOA · Seen Feb 2025
- K-Means ClusteringOA · Seen Feb 2025
- Minimum Sorted Erasure OperationsOA · Seen Jun 2024
- Count Analogous ArraysOA · Seen Mar 2024
- Get Maximum ScoreOA · Seen Mar 2024
- Better Compression 🦀OA · Seen Mar 2024
- Romanizer 🐡OA · Seen Mar 2024
- Flower Bouquets 💐OA · Seen Mar 2024