A fitness app stores the resistance levels of a cycling session in resistanceLevels, in stage order. Create workout plans by keeping some stages without changing their order or resistance levels.
A valid plan contains at least three stages. Its resistance levels strictly increase to one peak, then strictly decrease. Both an increase and a decrease are required.
Count all valid plans. Different selections of stage positions count separately, even when their resistance levels are identical.
int countWorkoutPlans(List<Integer> resistanceLevels)
resistanceLevels: The resistance level of each stage in the original session.1,000,000,007, or 0 if none exist.resistanceLevels.size() < 3, return 0.0 ≤ result < 1,000,000,007.Method call: countWorkoutPlans(resistanceLevels = List.of(4, 7, 10, 6))
Output: 4
Explanation: The valid plans have levels [4, 7, 6], [4, 10, 6], [7, 10, 6], and [4, 7, 10, 6].
Method call: countWorkoutPlans(resistanceLevels = List.of(4, 4, 9, 6, 6))
Output: 4
Explanation: Every valid plan has levels [4, 9, 6]. There are two choices for the stage with level 4 and two choices for the stage with level 6, giving four different selections.
Method call: countWorkoutPlans(resistanceLevels = List.of(15, 11, 7, 3))
Output: 0
Explanation: The resistance levels only decrease, so no selected plan can include an increase before its peak.