Problem Brief
Find Maximum Number of Balanced Combinations
OA
Given an array, the valid combinations are:
- [3]
- [6]
- [3]
- [3, 6, 3]
- [6, 3]
- [3, 6]
A combination is considered balanced if the last element is not the largest value in that combination. For example, [3, 6, 3] is balanced because the last element (3) is not larger than the others.
Your task is to find the maximum number of balanced combinations.
A possible custom case you can use could be - input = [99,25,69,28,32] output = 8
1Example 1
Input
arr = [3, 6, 3]
Output
2
Explanation
All possible combinations -
[3]
[6]
[3]
[3, 6, 3]
[6, 3]
[3, 6]
Balanced if the last element in the combination is NOT the greatest value.
Valid combinations -
[3, 6, 3] --> 3 is not the greatest
[6, 3] --> 3 is not the greatest
Constraints
Limits and guarantees your solution can rely on.
~