Problem 2657 · Medium

Find the Prefix Common Array of Two Arrays

Track the values seen so far in each permutation with two sets; each new value that the other side has already seen adds one to the running count.

Open the interactive visualisation