I looked at the code and understand why it works but I’m really not understanding the explanation given.
Specifically this part:
When the maximum capacity is achieved, the cross-section consists of a region in which the water level is nondecreasing, followed by a region in which the water level is nonincreasing.
What is meant by water level that is nondecreasing and nonincreasing? Given the below picture from the book, how does the region to the left of the max entry have nondecreasing water level and the right region nonincreasing?