Equalize The Arrays

Amazon interviews coding interview problem: Given two integer arrays, source and target, you may add 1 to any prefix or any suffix of source in one operation. Determine the minimum number of operations to make source equal to target, or return -1 if impossible. A clear arrays-and-operations interview question that focuses on understanding the problem and constraints.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: