Leetcode Problem

My code is failing in some test cases can u help me to correct it,
problem https://leetcode.com/problems/maximum-erasure-value/
my code>>> https://ide.codingblocks.com/s/484336

I am using prefix sum array logic

hello @joshisanjay8467

ans=max(ans,px[i]-px[s]);

i think here it should be s-1 othwrwise u may get wrong results where prefix array is unique and maximun

5 6 7 8 8 8

yeah tried it but still couldn’t figure out anything

check now

got it thankyou Aman bhaiya !!!

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.