I have the next situation in JavaScript:
const arr1 = [1,2,3]; // by default it is empty `[]`
const arr2 = [2,1,8,9];
arr1 can be changed dynamicly. So sometimes it could be [1,2,3,4] or [4,2,3] and so on.
The idea is next:
Depending by the arr1 to change the arr2 like,
if in arr1 is a number which is equal with a number from arr2,
then the number from arr2 that is equal should be deleted,
but if the new number that is added in arr1 is not exists in arr2 then it should be added in arr2:
EX:
arr1 = []; arr2=[2,1,8,9]// nothing happensarr1 = [1]; arr2=[2,8,9]// 1 from arr2 is deletedarr1 = [1,8,9,7]; arr2=[1,2,7]// 1,8,9 from arr2 is deleted, 7 is added
arr1and / orarr2can be very big array sized ( more than 1000 elements ? , 10000, 100000... ) ?