Problem · Dynamic Programming
Colorful Increasing Subsequences
Learn this problemProblem statement
Each candle has a height and one of k colors. Count subsequences whose heights are strictly increasing and that contain every color at least once. Return the result modulo 10^9 + 7.
Function
countColorfulSubsequences(heights: int[], colors: int[], k: int) → intExamples
Example 1
heights = [1,3,2,4]colors = [1,2,2,3]k = 3return = 2The two valid subsequences choose height 1, either height 2 or 3, and height 4.
Constraints
2 <= heights.length = colors.length <= 1001 <= k <= 71 <= colors[i] <= k1 <= heights[i] <= 10^9
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