Search
⌘K

Leetcode 2918. Minimum Equal Sum of Two Arrays After Replacing Zeros

Given two arrays where each 0 can be replaced by any positive integer, find the smallest possible equal sum you can make their totals both reach (or return -1 if impossible). The core challenge is a numeric feasibility check using each array's current sum and count of zeros: you need an S ≥ max(sum1+zeros1, sum2+zeros2) (and if an array has no zeros its sum is fixed to S) — return the minimal such S or -1.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.