Solution

When we order the two arrays in ascending order by time it becomes obvious that we can increment or decrement the number of gates by event type - either arrival or departure. Based on that we can maximize the number of gates, which will become the minimum number of necessary gates.