Math with Lego Blocks

Problem Overview

  • Replace zeros in two rows so their sums are equal and as small as possible.
  • Input: arrays rowA (n) and rowB (m) with positive integers and zeros for missing; Output: minimum achievable equal sum or -1 if impossible.
  • Constraints: 1 ≤ n,m ≤ 1e5; values in [0,10^4]; replacements must be positive.
  • Real-world context: teaching math with Lego blocks in a classroom.
  • From Citadel interviews; a coding interview problem and interview question.

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: