FastPrepFastPrep
Problem Brief

Flight Path Package Drop

FULLTIMEOA
See Cisco online assessment and hiring insights

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

1Example 1

Input
N = 5, xCoordinates = [1, 2, 3, 4, 5], M = 5, yCoordinates = [1, 2, 3, 4, 5]
Output
5
Explanation
:)
public int maxDropPointsCovered(int[] xCoordinates, int[] yCoordinates) {
  // write your code here
}
Input

N

5

xCoordinates

[1, 2, 3, 4, 5]

M

5

yCoordinates

[1, 2, 3, 4, 5]

Output

5

Sign in to submit your solution.