Count Undominated Points
Updated
Problem statement
You are given an array points, where points[i] = [x, y] is a point on a plane.
A point p dominates a point q when the x of p is strictly greater than the x of q and the y of p is strictly greater than the y of q. A point that is greater in only one coordinate, or equal in either one, does not dominate.
Return the number of points in points that are not dominated by any other point.
Function
countUndominatedPoints(points: int[][]) → intExamples
Example 1
points = [[1,2],[4,1],[3,5],[2,6],[0,3],[5,4]]return = 3No other point has both a larger x and a larger y than [3,5], and the same holds for [2,6] and [5,4], so these three points are not dominated. The other three are dominated: [3,5] dominates [1,2] and [0,3], and [5,4] dominates [4,1].
Example 2
points = [[2,2],[2,5],[5,2],[1,1]]return = 3[2,5] has the same x as [2,2], and [5,2] has the same y, so neither of them dominates [2,2]. Only [1,1] is dominated, for example by [2,2].
Example 3
points = [[-4,-2],[-1,0],[-3,-1]]return = 1[-1,0] dominates both other points, and no point dominates it.
Constraints
1 <= points.length <= 10^4points[i].length == 2-10^9 <= points[i][0], points[i][1] <= 10^9- No two points are equal.
More Nutanix Online Assessment questions
- Good SubsequencesOA · Seen Jul 2026
- Min Cost to Connect All PointsOA · Seen Jun 2026
- Digit Changes for a Multiple of 9OA · Seen Aug 2025
- Gas Station Loop StartOA · Seen Aug 2025
- Number of Players (for MTS2)OA · Seen Oct 2024
- Work Schedules (for MTS2)OA · Seen Oct 2024
- Minimum Operations to Convert ArrayOA · Seen Apr 2024
- No Adjacent CharactersOA · Seen Apr 2024
- Build a BST From a ListOA · Seen Nov 2022
- Delete Even-Valued Nodes From a Linked ListOA · Seen Nov 2022
Similar questions at other companies
- Capping Portfolio WeightsCapstone Investment Advisors · OA
- Count Servers With No Requests in a Time WindowIBM · OAIBM interview questions
- Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
- Largest Team Where Every Pair OverlapsWalmart · OAWalmart interview questions
- Maximum Distinct Values After Unit AdjustmentsBirla Pivot · OA
- Minimum Meeting RoomsJP Morgan Chase · OAJP Morgan Chase interview questions
- Minimize Task Resource ConsumptionNVIDIA · OANVIDIA interview questions
- Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
- Top K Frequent ElementsAmazon · OA · PHONE SCREEN
- Macaron Order PriceOpenAI · OAOpenAI interview questions