current_sum
), the minimum value (min_value
), and the maximum value (max_value
) of the hidden sequence.differences
array, updating current_sum
, min_value
, and max_value
accordingly.adjusted_min
) and maximum (adjusted_max
) values by adding lower
to min_value
and upper
to max_value
.adjusted_max
is less than lower
or adjusted_min
is greater than upper
, return 0 as no sequences are possible.adjusted_max - adjusted_min + 1
and return this value.