Why it is showing wrong?

Please review my code. Its working fine in online compiler.

hi @akhil54,
explain the logic of the algo u wrote (comment your code i mean)

the logic is simple, i have created two arrays which will store the next smallest element to right and next smallest element to left. Then I have calculated the area in the last loop and return the maximum area I got.

@akhil54 replace int with long long

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.

Not working with long long int. Have you gone through the code?


@akhil54

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.