Histogram Question

It is giving wrong answer for testcases.
Please tell the error.

Question :
HISTOGRAM
Find the largest rectangular area possible in a given histogram where the largest rectangle can be made of a number of contiguous bars.

Input Format:
First line contains a single integer N, denoting the number of bars in th histogram. Next line contains N integers, ith of which, denotes the height of ith bar in the histogram.

Constraints:
1<=N<=10^6 Height of each bar in histogram <= 10^9

Output Format
Output a single integer denoting the area of the required rectangle.

Sample Input
5
1 2 3 4 5
Sample Output
9

Hello @poorva2145

Try and use long long int instead of int because the largest rectangular area could go out of range of int

1 Like

Thank you.
It worked with long long int.

1 Like

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.