Trapping Rain Water (LC #42) is Meta's go-to hard array problem. Water trapped at position equals min(maxLeft, maxRight) minus height[]. The brute force computes max left and right for each position in . Optimize with prefix and suffix max arrays for time and space. The optimal two-pointer solution uses space: maintain left and right pointers with running maxes. Process the side with the smaller max. If height is less than max, add water. Update max and move pointer inward.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/meta-interview-prep/arrays-strings/trapping-rain-water
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███████████████████████████████████████████████████████████████████████████████████