**Description:**

Two arrays are called *similar* if one can be obtained from another by swapping at most one pair of elements.

Given two arrays, check whether they are *similar*.

**Example**

- For
`A = [1, 2, 3]`

and`B = [1, 2, 3]`

, the output should be

`areSimilar(A, B) = true`

; - For
`A = [1, 2, 3]`

and`B = [2, 1, 3]`

, the output should be

`areSimilar(A, B) = true`

; - For
`A = [1, 2, 2]`

and`B = [2, 1, 1]`

, the output should be

`areSimilar(A, B) = false`

.

**Input/Output**

**[time limit] 3000ms (cs)**

**[input] array.integer A**Array of integers.

*Constraints:*

`3 ≤ A.length ≤ 10`

,^{5}

`1 ≤ A[i] ≤ 1000`

.**[input] array.integer B**Array of integers of the same length as

`A`

.*Constraints:*

`B.length = A.length`

,

`1 ≤ B[i] ≤ 1000`

.**[output] boolean**`true`

if`A`

and`B`

are similar,`false`

otherwise.

**Tests:**

**Solutions:**

bool areSimilar(int[] A, int[] B) { List<int>b=new List<int>(B); List<int>a=new List<int>(A); bool isSwapped=false; if(A.Length>=3 && A.Length<=100000 && A.Length==B.Length) { for(int i=0;i<A.Length;i++) { int aI =A[i]; int bI =B[i]; if(1<=aI && aI<=1000 && 1<=bI && bI<=1000) { int f = b.IndexOf(aI,i); if(f==i) continue; else if(f>i) { if(!isSwapped) { int e = i; while(e<a.Count) { e=a.IndexOf(bI,e); System.Console.WriteLine(e); if(e<=i) break; if(b[e]==a[i]) break; else e++; } if(e>i && e<b.Count) { b[e]=b[i]; isSwapped=true; } else return false; } else return false; } else return false; } else throw new ArgumentOutOfRangeException(); } return true; } else throw new ArgumentOutOfRangeException(); }