WA in PEC005

I was solving PEC005
My Solution : https://www.codechef.com/viewsolution/36552021

Why is it giving WA after passing test cases? Can anyone tell me where I made a mistake in my code?

Just do a small change in your code, change the if condition to this
if(arr[i] >= arr[j] &&… (same as before))

1 Like

Wow, it worked ! Thanks a lot ! What was the idea behind the change though?

In the problem statement it was written that we need to find an increasing subsequence, not a strictly increasing subsequence. So,
this could also be an increasing subsequence
1 2 2 3 3 4
That’s why we changed the if condition to a[i] should be >= a[j].

1 Like

Oh yeah… Thanks :smiley: