Flight Path Package Drop

A pilot needs to fly over a 2D terrain exactly once and cover as many drop points as possible. Each drop point is represented by a 2D coordinate. The flight path can only be horizontal or vertical. Write an algorithm to determine the maximum number of drop points that can be covered in a single flight.

Input:

  1. Line 1: Integer N, the number of x-coordinates
  2. Line 2: N integers representing the x-coordinates
  3. Line 3: Integer M, the number of y-coordinates
  4. Line 4: M integers representing the y-coordinates

Output:

The maximum number of drop points that can be covered in a single horizontal or vertical flight

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: