can anyone help me finding alternative algorithm solution - without using sort()? : <pre><code>function areSimilar(a, b){
    return a.sort().join('') === b.sort().join('');
 }

 console.log(areSimilar([1, 2, 3], [1, 2, 3])); //true
 console.log(areSimilar([1, 2, 3], [2, 1, 3])); //true
 console.log(areSimilar([1, 2, 2], [2, 1, 1])); //false
</code></pre>

<p>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.</p>

<p>Given two arrays a and b, check whether they are similar.</p>

<p><strong>Example</strong></p>

<ul>
<li>For a = [1, 2, 3] and b = [1, 2, 3], the output should be
areSimilar(a, b) = true.</li>
</ul>

<p>The arrays are equal, no need to swap any elements.</p>

<ul>
<li>For a = [1, 2, 3] and b = [2, 1, 3], the output should be
areSimilar(a, b) = true.</li>
</ul>

<p>We can obtain b from a by swapping 2 and 1 in b.</p>

<ul>
<li>For a = [1, 2, 2] and b = [2, 1, 1], the output should be
areSimilar(a, b) = false.</li>
</ul>
