Mathpix Snip Interview Question

Trapped water leet code hard