Challenge: Find Two Pairs in an Array Such That a+b = c+d

Try to solve the Find Two Pairs in an Array Such That a+b = c+d problem.

We'll cover the following

Statement

Given an array of distinct integers, nums, determine whether there exist two pairs, (a,b)(a, b) and (c,d)(c, d), such that a+b=c+da + b = c + d, where aa, bb, cc, and dd are unique elements within the array. If there are multiple solutions, return any one of them.

Constraints:

  • 44 \leq nums.length 103\leq 10^3

  • 103-10^3 \leq nums[i] 103\leq 10^3

Examples

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.