(1) write a function F to find out the fisrt pair of numbers in the given array with a difference of D, i.e
(2) Input: an array with size N and the difference D. nums[i] is the weight of stone i. The elements could be integers or floating point numbers.
(3) Output: the indexes(i,j) of the fisrt pair of numbers with a difference to D, so that
Please check the code, the function name is find_onepair.
For int type , using hash map solves the problem.
Time:
Space:
For floating point numbers, due to the precision, I use tow pointer to find the wanted piar.
Time:
Space:
Please check the code, the function name is find_pairs.