Search⌘ K
AI Features

Solution: Find the Prefix Common Array of Two Arrays

C# solution for the Find the Prefix Common Array of Two Arrays problem using the Knowing What to Track pattern.

Statement

You are given two integer arrays A and B of equal length n. For each index i, consider the prefixes A[0..i] and B[0..i]. Define C[i] as the number of distinct values that appear in both prefixes. Return the array C of length n.

Note: A and B are permutations of the integers from 11 to nn.

Constraints:

  • ...