Minimum Coordinate-Conflict Deletions
Updated
Problem statement
You are given integer coordinate pairs in points. Delete as few input points as possible so that no two retained points share an x coordinate or share a y coordinate.
Return the minimum number of deletions. Each input occurrence is a separate point, including repeated coordinate pairs. An empty collection requires 0 deletions.
Function
minimumCoordinateConflictDeletions(points: int[][]) → intExamples
Example 1
points = [[0,1],[0,2],[1,0],[2,0]]return = 2At most one of the first two points and at most one of the last two points can remain. Keeping (0,1) and (1,0) achieves two deletions.
Example 2
points = [[0,0],[0,1],[1,0]]return = 1Keep (0,1) and (1,0), deleting only (0,0). A greedy first choice of (0,0) would keep too few points.
Example 3
points = [[1,2],[3,4],[5,6]]return = 0Every point already has a unique x and a unique y.
Constraints
0 <= points.length <= 500.- Every point is a pair
[x, y]. -10^9 <= x, y <= 10^9.
More Google Onsite Interview questions
- Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
- Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
- Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
- Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Reconstruct ItineraryTripjack · ONSITE INTERVIEWTripjack interview questions
- Largest Island After One Land ConversionAmazon · ONSITE INTERVIEW
- Spreadsheet Formula DependenciesAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
- Deepest Common Ancestors in a Multi-Parent DAGSalesforce · ONSITE INTERVIEWSalesforce interview questions
- Reconstruct ItineraryPhonePe · ONSITE INTERVIEWPhonePe interview questions
- Longest Decreasing Matrix Path with Limited RelaxationsDuolingo · ONSITE INTERVIEWDuolingo interview questions
- Making a Large IslandMeta · ONSITE INTERVIEWMeta interview questions
- Reconstruct ItineraryBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Course ScheduleOracle · ONSITE INTERVIEWOracle interview questions
- Package Install OrderVerily · ONSITE INTERVIEW