Two arrays are called similar if one can be obtained from another by swapping at most one pair of elements in one of the arrays.
Given two arrays a and b, check whether they are similar.
For a = [1, 2, 3]
and b = [1, 2, 3]
, the output should be
areSimilar(a, b) = true
.
The arrays are equal, no need to swap any elements.