Question: make learning more interactive and fun for students, a math teacher decides to teach a concept to students by using Lego blocks. There are 2

make learning more interactive and fun for students, a math teacher decides to teach a concept to students by using Lego blocks. There are 2 rows of legos, rowA (of length n) and rows (of length m). Both rows hold legos with positive integer values printed on them. However, some values (possibly, none) are missing. The missing values are denoted by 0. Students need to incorporate the missing values. The task is to replace each 0 with a positive integer such that the sums of both arrays are equal. Return the minimum sum possible. If it is not possible to make the sums equal, return -1.

Step by Step Solution

3.48 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Step 1 Find the difference between the sums Lets calculate the sum of the numbers in each row ignoring the zeros for now Call these sums suma for row ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!