Water trapped by any tower depends on the minimum of maximum height of towers on both sides.
This algorithm has a time complexity of O(N) and a space complexity of O(1), where N is the length of the input array.
[
add
]
[
|
|
...
]
Water trapped by any tower depends on the minimum of maximum height of towers on both sides.
This algorithm has a time complexity of O(N) and a space complexity of O(1), where N is the length of the input array.