Whats wrong this code .Getting all test case faild

public static long hist(int[] arr, StacksUsingArrays stack)
throws Exception {

	int i=0;
	long max=0;
    while(i<arr.length){
		if(stack.isEmpty()||arr[i]>=arr[stack.top()]){
			stack.push(i++);
		}
		else{
			int top=stack.pop();
			int area=(stack.isEmpty()?arr[top]*1:arr[top]*(i-stack.top()-1));
			max=Math.max(max,area);
		}
		
	}
	while(!stack.isEmpty()){
			int top=stack.pop();
			int area=(stack.isEmpty()?arr[top]*1:arr[top]*(i-stack.top()-1));
			max=Math.max(max,area);
		}
		return max;
    
}

@khans5854,

you have to do arr[top]*i instead of arr[top]*1. Also use long instead of int.

https://ide.codingblocks.com/s/224022 corrected code

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.