Company: uber_6oct
Difficulty: medium
Count Profitable Segments Problem Description In Uber's trip analysis system, a profitable segment is defined as a continuous stretch of rides containing a specified number of premium rides. Each ride in the list is represented by an integer value: If the value is odd, the ride is classified as premium. If the value is even, the ride is classified as regular. Given a sequence of rides and a target number of premium rides, determine how many distinct profitable segments can be formed. Distinct segments are those defined by unique starting and ending positions in the ride sequence, even if the rides inside overlap. Complete the function countProfitableSegments with the following parameters: int ridelist[n] : an array representing rides taken int targetPremiums : the exact number of premium rides required for a segment to be profitable Returns: int : the total number of profitable segments Examples Example 1: Input: ridelist = [7, 10, 3, 6, 5], targetPremiums = 2 Output: 4 Explanation: Pr