Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Consider keeping a frequency array that stores the count of occurrences of each number till index i.
If a number occurred two times, it means it occurred in both A and B since they’re both permutations so add one to the answer.