Find Maximum Number Drop Points Connected
Updated
Problem statement
A pilot must drop food packets over a terrain. The drop points have integer coordinates: point i is at (x[i], y[i]).
The pilot flies over the terrain once, along one straight path that is either horizontal or vertical (not diagonal, and not a mix of the two). So a path covers either all points with the same x coordinate, or all points with the same y coordinate.
A path is valid only if it connects more than one drop point; a single point does not make a path.
Return the maximum number of drop points covered by one valid path. If no valid path exists, return 0.
Function
findMaximumNumberDropPointsConnected(x: int[], y: int[]) → intExamples
Example 1
x = [2, 3, 2, 4, 2]y = [2, 2, 6, 5, 8]return = 3There are 5 coordinates- (2,2), (3,2), (2,6), (4,5) and (2,8). The best path is the horizontal one covering (2,2), (2,6) and (2,8). So, the output is 3.
Constraints
2 ≤ x.length ≤ 700y.length == x.length0 ≤ x[i], y[i] ≤ 10^9- All points are distinct.
More Cisco interview questions
- Check if a String Is a PalindromePHONE SCREEN · Seen Nov 2026
- Find Unique ElementsPHONE SCREEN · Seen Nov 2026
- First Letter to Appear TwicePHONE SCREEN · Seen Nov 2026
- Middle of a Linked ListPHONE SCREEN · Seen Nov 2026
- Reverse a Linked ListPHONE SCREEN · Seen Nov 2026
- Reverse a StringPHONE SCREEN · Seen Nov 2026
- Valid ParenthesesPHONE SCREEN · Seen Nov 2026
- K-Step Bit Flip with RetentionPHONE SCREEN · Seen Nov 2026
- Todo Task Manager OperationsONSITE INTERVIEW · Seen Oct 2026
- Find the Duplicate Number Without Modifying the ArrayONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
- Task Scheduler with CooldownGoDaddy · OA
- Minimum Distinct Prefix CostChubb · OAChubb interview questions
- Minimum Distinct Prefix CostGoldman Sachs · OAGoldman Sachs interview questions
- Rearrange Songs by AuthorZomato / Eternal · OAZomato / Eternal interview questions
- 🐘 Keep Them Apart 🦙QRT · OA
- Minimum Operations to Make Array ValidAmazon · OA
- Maximize Palindromic WordsSquarepoint Capital · OASquarepoint Capital interview questions
- Viral Content BalancerTikTok · OATikTok interview questions
- Merging PalindromesOld Mission · OA