← ALL NOTES
Array

2657. Find the Prefix Common Array of Two Arrays

Given two permutations A and B of 1..n. For each prefix of length i+1, count how many numbers appear in both A[0..i] and B[0..i] (the prefix common array). Track which numbers have appeared in both…

Loading…