count of size n+1 to store the counts of elements (since elements are from 1 to n).C of the same length as A and B.common to keep track of the number of common elements seen so far.A and B using an index i:
a. Increment count[A[i]].
b. If count[A[i]] becomes 0 after incrementing, increment common.
c. Decrement count[B[i]].
d. If count[B[i]] becomes 0 after decrementing, increment common.
e. Set C[i] to common.C.