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:
- Line 1: Integer
N, the number of x-coordinates - Line 2:
Nintegers representing the x-coordinates - Line 3: Integer
M, the number of y-coordinates - Line 4:
Mintegers representing the y-coordinates
Output:
The maximum number of drop points that can be covered in a single horizontal or vertical flight
Examples
01 · Example 1
N = 5 xCoordinates = [1, 2, 3, 4, 5] M = 5 yCoordinates = [1, 2, 3, 4, 5] return = 5
:)
More Cisco problems
- Collect CoinsSeen Jun 2025
- FizzBuzz ProblemSeen May 2025
- Find Largest Sum Contiguous SubarraySeen May 2025
- Find Largest Sum of Continuous SequenceSeen May 2025
- Find Palindrome Sub-stringSeen May 2025
- Count Numbers with Digit SumSeen Mar 2025
- Maximum Chocolates from Jars (L.C. 198 :)Seen Mar 2025
- Find Elements Largest in Row Smallest in ColumnSeen Mar 2025
public int maxDropPointsCovered(int[] xCoordinates, int[] yCoordinates) {
// write your code here
}
N5
xCoordinates[1, 2, 3, 4, 5]
M5
yCoordinates[1, 2, 3, 4, 5]
expected5
sign in to submit