Container With Most Water Algorithm

Distilled water is water that has been boiled into vapor and condensed back into liquid in a separate container. Thus, distilled water is one type of purified water. Drinking water has been distilled from sea water since at least about ad 200, when the procedure was clearly described by Alexander of Aphrodisias. Its history predates this, as a passage in Aristotle's Meteorologica (II.3, 358b16) refers to the distillation of water. Captain Israel Williams of the Friendship (1797) improvised a manner to distill water, which he described in his journal.
class Solution {
public:
    int maxArea(vector<int>& height) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
        if (height.size() < 2)
            return 0;
        int left = 0;
        int right = height.size() - 1;
        int maxarea = 0;
        while (left < right) {
            maxarea = max(maxarea, min(height[left], height[right]) * (right - left));
            if (height[left] < height[right]) 
                left += 1;
            else
                right -= 1;
        }
        return maxarea;
    }
};

LANGUAGE:

DARK MODE: