Sir but it wont for all cases isnt it?

example if the input is
array size=4
1 1 3 3
d=2(difference)
according to algorithm
i=0
a[i]=1 and a[i+1]=1 both can be paired because difference =0

so we will increment i++ , i=1
now a[i] =1 and a[i+1]=3 difference is 2 so it can be paired
now we do i+=2

i becomes i=3
which will break the condition so we only get one pair but 2 pairs are possible isnt it??

Hey @tejasddongare
Here we will increment i+=2 and not i++ ,please rewatch the video :slight_smile:

no you didnt understood i++ if the first element is not is paired then we are going to do i++ isnt it??? can you please provide the code for this problem

Hey @tejasddongare
https://www.codechef.com/viewsolution/37632710
Ask if u dont understand

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.