public class LargestRecInDist {
public int largestRectangleArea(int[] h) {
int max = 0;
Stack ss = new Stack();
int[] arr = Arrays.copyOf(h, h.length +1);
for(int i = 0; i < arr.length; i++){
while(!ss.isEmpty() && arr[ss.peek()] > arr[i]){
max = Math.max(max, arr[ss.pop()] * (ss.isEmpty()? i: i -ss.peek() -1));
}
ss.push(i);
}
return max;
}
/*
public int largestRectangleArea(int[] hist) {
int len = hist.length;
int i,j,k;
int maxSum=0,prev=-1;
for(i=0;i=0;j--)
if(hist[j]