• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

238
Views
Minimum number of moves to equalize two arrays of numbers

can you please help me solve this problem in JavaScript with explanation.

There are two arrays of integer arr1 and arr2 one move is defined as an increment or decrement of one element in an array. Determine the minimum number of moves to match arr1 with arr2.

Input: nums1 = [1,2,3,4,5,6], nums2 = [1,1,2,2,2,2] Output: 3

Explanation: You can make the sums of nums1 and nums2 equal with 3 operations. All indices are 0-indexed.

  • Change nums2[0] to 6. nums1 = [1,2,3,4,5,6], nums2 = [6,1,2,2,2,2].
  • Change nums1[5] to 1. nums1 = [1,2,3,4,5,1], nums2 = [6,1,2,2,2,2].
  • Change nums1[2] to 2. nums1 = [1,2,2,4,5,1], nums2 = [6,1,2,2,2,2].
about 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error