Need help to approach this question (Walmart SDE Intern Test)

Hey folks last month Walmart came to our campus and there was this one coding question that I wasn’t able to solve and the weightage of this question was quite heavy half of the test was dependent on this question. Its been almost one month and i am still not able to approach this problem so please help don’t need the whole code even the approach will be enough

I think since on each operation we are doing +2 or -2 , so sum of both arrays must be same to make them equal else -1.
If sum is equal , then find elements which are already present in both , now with remaining elements just sort them in both arrays and difference between all elements must be same.
So answer would be (difference)/2.
Please tell if it is correct or not