Pair of roses problem

question- https://hack.codingblocks.com/contests/c/509/696
code - https://ide.codingblocks.com/s/37837

pls help wrong unwanted output

https://ide.codingblocks.com/s/38068

I have made changes in your code and also commented your mistake.
There was a very small, but silly mistake.

thank you for pointing out my mistake… bt its not submitting on hacker blocks

code- https://ide.codingblocks.com/s/38073

when you are taking the difference i.e. b[count][2]=a[k]-a[j]; , take the absolute difference.
Also, your code can be more efficient as there is no need to use the extra space in this ques.
I have just updated your code, you can refer this https://ide.codingblocks.com/s/38148

1 Like

thank you didi…
one more question- https://hack.codingblocks.com/contests/c/509/1427
code- https://ide.codingblocks.com/s/38151
passing 4 out of 5 cases…