I took the test earlier today and I couldn't figure out how to approach this problem without using a solution that'd give me TLE. Any idea is appreciated!
I'm supposed to find a minimum sum of abs difference of elements in the same position. What I mean by abs difference is abs(arr1[i] - arr2[i]).
You can change 1 element in arr1 with another element in arr1 once or leave it as is. For example, if you have arr1 = [1, 2, 3, 4], you can change it to [1, 2, 3, 1] or [1, 2, 3 ,3], etc.
Ex:
arr1 = [1,2,3,4]
arr2 = [1,2,4,0]min sum of abs difference without any change would be 0 + 0 + 1 + 4 = 5.
I could change 4 in arr1 to 1 so that min sum abs diff becomes 0 + 0 + 1+ 1 = 2
The answer for this would be 2.
Any help is appreciated!