Skip to content

Instantly share code, notes, and snippets.

@Siyu-Lei
Created May 22, 2018 22:25
Show Gist options
  • Save Siyu-Lei/a13b2e64411d000293840520887f6182 to your computer and use it in GitHub Desktop.
Save Siyu-Lei/a13b2e64411d000293840520887f6182 to your computer and use it in GitHub Desktop.
class Solution {
public int maxArea(int[] height) {
int start = 0;
int end = height.length - 1;
int max = 0;
while (start < end) {
int min = Math.min(height[start], height[end]);
max = Math.max(min * (end - start), max);
while (height[start] <= min && start < end) {
start++;
}
while (height[end] <= min && start < end) {
end--;
}
}
return max;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment