Bitonic Partitioning
Updated
Problem statement
Partition arr into at least three non-empty contiguous segments. Represent each segment by its arithmetic mean.
A partition is valid when the sequence of means is strictly increasing up to one peak segment and then strictly decreasing. There must be at least one segment before and after the peak.
Return the exact number of valid partitions as a decimal string.
For [1, 3, 2, 1], the three valid partitions are:
[1] | [3, 2] | [1].[1] | [3] | [2, 1].[1] | [3] | [2] | [1].
Function
bitonicPartitioning(arr: int[]) → StringExamples
Example 1
arr = [1, 3, 2, 1]return = "3"The three valid partitions are listed in the statement.
Example 2
arr = [1, 2, 3, 4, 3, 2, 1]return = "49"Enumerating all cut positions and keeping only strictly increasing-then-decreasing mean sequences gives 49.
Constraints
1 <= arr.length <= 100.-10^9 <= arr[i] <= 10^9.
More Rubrik interview questions
- Colored Rooted TreeONSITE INTERVIEW · Seen Nov 2026
- Delete and Freeze GameOA · Seen Nov 2026
- Delete K Subsets for Maximum ScoreOA · Seen Nov 2026
- Distribute Elements Into Two Arrays IIOA · Seen Nov 2026
- Minimum Replacements to Sort the ArrayOA · Seen Nov 2026
- All Balanced Strings from Minimum Parenthesis InsertionsONSITE INTERVIEW · Seen Nov 2026
- Insert into a Left-Complete Binary TreeONSITE INTERVIEW · Seen Oct 2026
- Thread-Safe Request Counts by AttributeONSITE INTERVIEW · Seen Oct 2026
- Minimum Swaps To Binary PalindromeOA · Seen Apr 2026
- Get Minimum OperationsOA · Seen Nov 2024
Similar questions at other companies
- At Most K Jumps with Quadratic Transition CostInfosys · OAInfosys interview questions
- Largest Consistent Visiting GroupAuxoAI · OA
- Optimize Discount Selection Under a Point BudgetPalantir · OAPalantir interview questions
- Maximum Index-Weighted Sum with Disjoint SwapsVisa · OAVisa interview questions
- Maximum Sum of HeightsVirtu Financial · OAVirtu Financial interview questions
- Pressure-Isolation Shutdown OrderIntuit · OAIntuit interview questions
- Get Minimum IncrementIBM · OAIBM interview questions
- Jump Game with Prime-3 StepsUber · OAUber interview questions
- Maximum Payout with Context SwitchesPhonePe · OAPhonePe interview questions
- Maximize Array Beauty After DeletionsPoint72 · OAPoint72 interview questions