# Big O of finding symmetrical diffrences of array

Can you help me with the time complexity of this solution for finding symmetrical differences problem and explain in detail including the case where there are more than two input arrays.

https://www.freecodecamp.org/learn/coding-interview-prep/algorithms/find-the-symmetric-difference

``````let symmetricDiffTwoArray=(firstArray,secondArray)=>{

let resultArray=[];
for(let i=0;i<firstArray.length;i++){
let currentElement=firstArray[i];
if(resultArray.indexOf(currentElement) === -1 && secondArray.indexOf(currentElement) === -1)
resultArray.push(currentElement);
}

for(let j=0;j<secondArray.length;j++){
let currentElement=secondArray[j];
if(resultArray.indexOf(currentElement) === -1 && firstArray.indexOf(currentElement) === -1)
resultArray.push(currentElement);
}

return resultArray;
}
function sym(...args) {
let symmetricDiff=args.reduce(symmetricDiffTwoArray,[]);
return symmetricDiff;
}

console.log(sym([1, 2, 3], [5, 2, 1, 4],[7,4]));

``````

What do you mean by input arrays?

function sym(…args) can take multiple arguments let’s say 2,3,4 or more no of arrays, so
let’s say k no of arrays are passed to the function then how will be the time complexity get affected by it.

In this particular challenge there are only ever 2 arrays passed, so it does not change anything.

Here is the last test case for the challenge containing 6 arrays

``````sym([3, 3, 3, 2, 5], [2, 1, 5, 7], [3, 4, 6, 6], [1, 2, 3], [5, 3, 9, 8], [1])`  should contain only eight elements.
``````