Maximize Similarity
Problem Overview
- Given arrays inv1 and inv2 of length n, maximize the count of indices i where inv1[i] == inv2[i].
- Allowed operation: pick i ≠ j with inv1[j] > 0; do inv1[i]++ and inv1[j]-- any number of times.
- Constraints: 1 ≤ n ≤ 1e5; 1 ≤ inv1[i], inv2[i] ≤ 1e4. Output the maximum achievable similarity.
- Context: Amazon inventory management; an Amazon interviews 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:
