Tap here to switch tabs
Problem
Submissions

Problem: Transform Array Using Pair Operations

Try to solve the Transform Array Using Pair Operations problem.

Statement

You are given two integer arrays source and target, both of the same length.

In one operation, you can perform the following steps:

  • Choose two distinct indices i and j.

  • Choose any integer delta.

  • Update source[i] to source[i] + source[j] - delta.

  • Update source[j] to delta.

Return true if it is possible to transform source into target after applying any number of operations, or false otherwise.

Constraints:

  • 2≤2 \leq source.length == target.length ≤105\leq 10^5

  • −109≤-10^9 \leq source[i], target[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Transform Array Using Pair Operations

Try to solve the Transform Array Using Pair Operations problem.

Statement

You are given two integer arrays source and target, both of the same length.

In one operation, you can perform the following steps:

  • Choose two distinct indices i and j.

  • Choose any integer delta.

  • Update source[i] to source[i] + source[j] - delta.

  • Update source[j] to delta.

Return true if it is possible to transform source into target after applying any number of operations, or false otherwise.

Constraints:

  • 2≤2 \leq source.length == target.length ≤105\leq 10^5

  • −109≤-10^9 \leq source[i], target[i] ≤109\leq 10^9