max_captured to 0 to keep track of the maximum number of enemy forts captured.current_captured to 0 to keep track of the current number of enemy forts captured while traversing a segment.forts array using an index i.
forts[i] is 1 (your fort), reset current_captured to 0.forts[i] is 0 (enemy fort), increment current_captured.forts[i] is -1 (empty position) and current_captured is greater than 0, update max_captured with the maximum of max_captured and current_captured, then reset current_captured to 0.max_captured as the result.