#trapping-rain-water

[ follow ]
Medium
5 months ago
Scala

Two Pointers technique: Trapping Water (Array)

The algorithm for trapping rain water has a time complexity of O(N) and a space complexity of O(1).
The algorithm uses two pointers to track the tallest towers seen from the left and right, and calculates the trapped water based on the minimum of the maximum heights on both sides. [ more ]
[ Load more ]