Reported interview periodNot available
Water held between bars
Bars of width one stand along a line at the given heights. Return how many units of water stay trapped between them after it rains.
Practice focusRequirements - Line 1 is the bar count; line 2 lists the height of each bar from left to right. - The water above a bar is bounded by the shorter of the tallest bars on its left and on its right, minus the bar's own height. - Bars at the two ends hold nothing, and a stretch that only falls or only rises holds nothing. - Return the total as a decimal string with no per-bar breakdown and no trailing newline. - Heights are non-negative integers; the total fits in ordinary integer arithmetic. - An input with zero or one bar traps nothing.