Pair of roses problem

here is my code:-
tell me why it is not running

hey @Love your logic for solving this problem is wrong you are searching if it is possible to generate a pair with given difference, but what if the minimum difference is greater than mid you never check it
for example
1
2
1 7
8

@Love One of the correct approaches would be

  1. store occurrence of each element in map
  2. iterate array and check if target - arr[i] exists it if exists compare their difference with the minimum difference and store the minimum difference
  3. print the solution for minimum difference
    Here is the code for the same
    https://ide.codingblocks.com/s/192957