public int maxArea(int[] height) {

    if (height.length < 2) {
      return 0;
    }

    int head = 0, tail = height.length - 1;
    int max = Math.min(height[head], height[tail]) * (tail - head);

    while (head < tail) {

      if (height[head] <= height[tail]) {
        head++;
      } else {
        tail--;
      }

      if (head < tail) {
        int temp = Math.min(height[head], height[tail]) * (tail - head);
        if (temp > max) {
          max = temp;
        }
      }
    }

    return max;
  }