Company: citi_14oct
Difficulty: medium
Largest Pothole Indicator Problem Description There is a road consisting of N segments (numbered from 0 to N-1) described by an array R of integers. The K-th segment is described by an integer R[K]. If the segment is smooth (there is no pothole in it), then R[K] = 0; otherwise it contains a pothole of depth R[K]. Consecutive potholes join together and create a larger group of potholes. The pothole indicator is the number of consecutive single potholes that have joined into a pothole group, multiplied by the depth of the deepest pothole among them. For example, the indicator for a group of three consecutive joined potholes of sizes [1, 4, 1] is 3 * 4 = 12. What is the largest pothole indicator on the entire road? Write a function: int solution(vector<int> &R); that, given an array R of N integers, returns the largest pothole indicator on the road. Examples Example 1: Input: R = [0, 2, 1, 1, 0, 4, 1] Output: 8 Explanation: The potholes in the fragment [2, 1, 1] join into one po