As reported: Microsoft SDE2 (Oct 2025), hiring manager round: behavioural questions and a lot about the current project, ending with Trapping Rain Water.
Given n non-negative integers representing an elevation map where each bar has width 1, compute how much water it traps after raining.
This is LeetCode 42 — Trapping Rain Water.
Example 1
height = [0,1,0,2,1,0,1,3,2,1,2,1] -> 6
Example 2
height = [4,2,0,3,2,5] -> 9
Constraints: 1 ≤ n ≤ 2·10^4; 0 ≤ height[i] ≤ 10^5.
Code runner format: one JSON value per line: height (LeetCode's test-case format). Implement trap(height); the harness prints the result.