← 返回 meta 的题目列表Transform Two Arrays and Solve Equation
类型:online_judge
meta
Given two integer arrays A and B, find all integer pairs (x1, y1) and (x2, y2) such that x1 is selected from A, y1 from B, x2 from A, and y2 from B, satisfying the equation x1 + x2 = y1 + y2.
Input Description:
Integer arrays A and B, each of length n, with integer values ranging from 1 to 1000.
Output Description:
Return a two-dimensional array containing the integer pairs (x1, y1), (x2, y2) that satisfy the condition.
Example 1:
Input: A = [1, 2, 3], B = [3, 2, 1]
Output: [[[1, 2], [3, 0]], [[2, 3], [1, 4]]]
Constraints:
Length of A and B should not exceed 1000.
Elements in the arrays can be negative.
Example
Input
[1, 2, 3]
[3, 2, 1]