Ruman and Pull Request

Problem :
My solution :

Please have a look at a problem and my solution
and please figure out what is wrong in my solution

@anon55659401 @ssrivastava990 @guitarlover

Okay, I found an error. You are not updating the start and end indices for the answer (denoted by st and en in your code). Look at the if statement at line 48. You’re not updating these indices there (for this block).

My suggestion: Remove the if (mid < st) statement at line 51 and just generalize st = mid; en = i; for the if block starting at line 48.

Though I’ve not really looked at it closely but I hope it will be fine then. Please check and let me know about it.

Hope it helps!
Happy Programming!

1 Like

Ok i got it
As you have seen my solution
Is my approach correct for this problem

I’ve not looked very closely. But yes, it seems fine to me as of now. I think you should check by submitting it now.

When editorials of this contest will be published ?

It might take some time. I’ll try to do it by weekend, but that’s not a promise. I’m just trying to finish things as soon as possible.

1 Like

It worked finally AC

1 Like

Nice problem of binary search

1 Like

Actually it can also be solved using sliding window algorithm (modifying Kadane’s algorithm). But yes Binary search will also work.