Question: Please use C++ and the same exact function header above. Upvotes will be given for the correct answer! Given an array of distinct integers, find

Please use C++ and the same exact function header above. Upvotes will be given for the correct answer!
Given an array of distinct integers, find if there are two pairs (a, b) and (c, d) such that a+b=c+d, and a, b, c, and d are distinct elements. If there are multiple elements, the function should print all pairs that work. You may assume that for any pair (a, b), there is at most one other pair (c,d) that sums to a+b. Example: Input: [3, 4, 7, 1, 2, 8] Output: (3, 2) and (4,1) 1/5 (3, 7) and (2, 8) //10 (3, 8) and (4, 7) 1/11 (7, 2) and (1, 8) 1/9 Input: [65, 30, 7, 90, 1, 9, 8] Output (nothing): // Prints out all different pairs in input_vec that have same sum. 1/ Expected Runtime: 0(2) void two-pair_sums (const vector (int> &input_vec, ostream& out)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
