Codeforces problem- Interesting Subarray!

It is showing wrong ans on TestCase 2;
problem - http://codeforces.com/contest/1270/problem/B
soln:
https://ide.codingblocks.com/s/172325

https://codeforces.com/contest/1270/submission/67956677
i don’t think you need to check like that way.
you can see the test case clearly where you are wrong.
just check if two adjacent elements have a difference of more than 2 that is your answer :slight_smile:

Yeah i read the tutorial and it states the same but I just want to know the problem in my code…?
I m checking left and right of max element of array and trying to find out where the condition holds true!
Pls correct me.

You solution does not pass the sample tests as well.

Check @shim98 solution logic.

Check out this soln : https://ide.codingblocks.com/s/172325

First of all your code goes out of bounds.

1
0 0

for this test case.
Rectify that.
Your solution does passes the initial test case…
your solution fails these test cases though.

1
16
1 2 3 4 4 4 2 4 4 4 4 4 5 5 5 5

Answer should be

YES
6 7

I am not able to follow logic of your solution that well. Tbh sometimes understanding other’s code is like understanding a handwriting but i told you the test cases that didn’t pass so i hope you understand well now :slight_smile:

Its totally fine man and thanks a lot for the testCases. Also i got to know the problem in my code! Thanks again. :):wink:

1 Like