Unable to find the mistake (D. Remove One Element Div3 ) - Please Help

Problem Link :- (D. Remove One Element
My Code :- My Code

Ive been struggling for 3 hours straight and I’m still not able to find the solution to and get an AC in the problem . You can get the question above .

Approach :
I’m Actually storing the intervals in which there are strictly increasing elements .
and the I’m checking whether the two consecutive intervals can be our answer , as consecutive might have a case in which there is one element which should be removed , and the two intervals should be merged resulting in our answer . Thus iterating over all the intervals and storing the maximum possible answer , we should be able to tell our answer .

I’m Not able to get the answer , somebody Please help .

Also I would like to know how you people take care of the test cases , and how you guys debug the answer , and how can we debug the answer fast in contests . Are there any specific instructions/commands , that must be followed , how can we take care of the big test cases ???

consider this test case
4
2 3 1 4
here your output is 2 but clearly correct output is 3
just add one more condition while iterating over intervals and you will get AC…
in this code you can check that extra condition

and for debugging if you are not able to find out error in code using any debugging tool…try to generate counter test cases …in short contests i usually guess small test cases .

Thank you very much , your answer really made my concept clear . And extra thanks for the extra tips . :smiley:

1 Like