Problem · Array
Bitonic Partitioning
Given an array arr of size n (where n <= 100), find the number of ways to partition the array. The elements should be divided into partitions. The goal is to make the representative array bitonic. For each partition, the average of the array represents the partition.
We should have at least 3 partitions to establish first increasing and then decreasing. Additionally, we only consider partitions that are strictly increasing and then strictly decreasing.
For example, if we have an array of length 4, arr = [1, 3, 2, 1], the valid partitionings are:
In all 3 partitions, the sequence first increases and then decreases.
Examples
01 · Example 1
arr = [1, 3, 2, 1] return = 3
n/a
02 · Example 2
arr = [1, 2, 3, 4, 3, 2, 1] return = 49
n/a
Constraints
1 < n <= 100-10^9 <= arr[i] <= 10^9More Rubrik problems
public int bitonicPartitioning(int[] arr) {
// write your code here
}
arr[1, 3, 2, 1]
expected3
sign in to submit