Count Bitonic Subsequences
Updated
Problem 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 Online Assessment questions
- 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
- Binary Search Tree IteratorOA · Seen Nov 2023
- Binary Tree Level Order TraversalOA · Seen Nov 2023
Similar questions at other companies
- Range Maximum Subarray Sum QueriesInMobi · OAInMobi interview questions
- Minimum Bridge TurnbacksBNSF Railway · OABNSF Railway interview questions
- Maximum Profit from an Increasing Price TripletOdoo · OAOdoo interview questions
- Longest Increasing Subsequence With Bounded Adjacent DifferenceGoogle · PHONE SCREENGoogle interview questions
- Longest Increasing Subsequence With Bounded Adjacent DifferenceAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Volunteer Awards: Totals Divisible by KNutanix · ONSITE INTERVIEWNutanix interview questions
- Expected Steps Until a Random Walk Gets Far From ZeroOptiver · OAOptiver interview questions
- Magic Number Range CounterGraviton · OA
- At Most K Jumps with Quadratic Transition CostInfosys · OAInfosys interview questions
- Largest Consistent Visiting GroupAuxoAI · OA