The two questions are rather different. If $A$ and $B$ are given as unsorted lists, then one thing you could do is to sort $A$ and $B$ together, putting elements of $A$ before those of $B$ in case of ties, and then do a simple linear scan. This runs in $O(n\log n)$ time, where $n$ is the length of both arrays.
If the arrays are sorted then you can just merge them, in $O(n)$, and continue as before.
If the "arrays" (really sets) are given as bit-vectors, then you can use bitwise operations; details left to you.