I am not able to figure out the logic, could you help me out?
How to approach this problem. Pair of Roses
@alter hey ,isme apko woh pairs print krne hai jinka total sum available money jitna ho ,to pairs with given sum print krne hai to ek efficient soln ye hai hai sort krlo array fir two pointers lelo first pointer starting of array pr and second wala last pr agr both pointer ka sum given sum ke brabar hua to print kro pairs and pehle pointer ko age bdhayo and last wale ko piche and if both pointers ka sun less hai given sum se ti firstpointer ++ krdo else second pointer - -.hope you get it 
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.
for the array - [5 10 2 6 8 4 10] and M = 10 according to your two pointer approach if I sort this array and then find out the pair then it will come out as 2 and 8 but the expected output should be 4 and 6 due to the condition given in the question i.e. If there are multiple solutions print the solution that minimizes the difference between the prices i and j. After each test case, you must print a blank line. How can I ensure I get the correct answer?
yes, I am actually trying to figure out how can i apply divide and conquer technique on this problem. Can you help me out?
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.