Help with approach

sol: https://ide.codingblocks.com/s/415797

prob: https://hack.codingblocks.com/app/contests/2022/211/problem

approach:

I’m trying to go towards the left and right side of the current bar and see if I can add them to my answer or not and I’m doing this procedure for every element and at the end I’m returning which ever answer is the largest

getting seg fault

Hey @raghav007
You were allocating too much space hence segmentation
Second there was error in ur logic as well so please re read the question


Corrected ur code though it will give TLE because its O(n^2)
U have to do it in o(n)

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.