Company: Arcesium_28may
Difficulty: medium
Two neighboring islands — North Island and South Island — each have a row of grain processing factories aligned from top to bottom. Each factory specializes in processing a specific type of grain (e.g., Rice, Wheat, Corn, etc.). You are tasked with building bridges between the two islands to connect factories that process the same type of grain. However, due to engineering constraints: A bridge can only connect factories of the same grain type (e.g., Wheat ↔ Wheat). Each factory can participate in at most one bridge. Bridges must be built in a way that they do not cross each other (to avoid construction overlaps and maintain safety). Your objective is to determine the maximum number of non-crossing bridges you can construct between factories of the same grain type across the two islands. Input: Two arrays of length n: northIsland[0...n-1] : grain types of factories on the North Island. southIsland[0...n-1] : grain types of factories on the South Island. Each element is