Closest Point to a Line
Updated
Problem statement
The line is a*x + b*y + c = 0, with coefficients given by line = [a,b,c]. Each row of points is an [x,y] point.
Return the coordinates of the point with the smallest perpendicular distance to the line. If several points tie, return the one with the smallest original index.
Function
perpendicularDistance(points: int[][], line: int[]) → int[]Examples
Example 1
points = [[1,2],[5,6],[7,2],[2,7],[4,8]]line = [1,-1,2]return = [1,2]The absolute line evaluations are 1,1,7,3,2. All distances share the divisor sqrt(2). The first two points tie for the minimum, so return the first point [1,2].
Example 2
points = [[0,0],[3,3]]line = [1,-1,0]return = [0,0]Both points lie on the line and have distance zero. The first point wins the tie.
Constraints
- For this exercise, assume 1 <= points.length <= 100000.
- Each points row contains exactly two coordinates.
- For this exercise, assume -1000000 <= points[i][j] <= 1000000.
- line contains exactly three integers [a,b,c].
- For this exercise, assume -1000000 <= line[i] <= 1000000.
- At least one of a and b is nonzero.
Source note: Original OA task images and any included source example. The practice contract follows the rules stated in the problem and source note.
More Adobe Online Assessment questions
- Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
- Top-Funded Villages and ProjectsOA · Seen Aug 2026
- Count Parent Nodes With a Target SumOA · Seen Aug 2026
- Largest Binary Number by ConcatenationOA · Seen Aug 2026
- Count Events by CategoryOA · Seen Aug 2026
- Graph M-ColoringOA · Seen Aug 2026
- Hall of Shifting TilesOA · Seen Aug 2026
- K-th Ancestor Subtree Preorder QueryOA · Seen Aug 2026
- Maze ReachabilityOA · Seen Aug 2026
- Minimum Numeric Code TransformationOA · Seen Aug 2026
Similar questions at other companies
- Optimal Central WarehouseGoogle · ONSITE INTERVIEWGoogle interview questions
- Max Points on a LineUber · PHONE SCREENUber interview questions
- Max Points on a LineLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
- Maximum Visible DronesAnduril · PHONE SCREENAnduril interview questions
- Count Overlapping Square PairsRamp · OARamp interview questions
- Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
- Capping Portfolio WeightsCapstone Investment Advisors · OA
- Count Subarrays with a Perfect-Square ProductMicrosoft · OAMicrosoft interview questions
- Repeated Mirror XORMathWorks · OAMathWorks interview questions
- Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
Adobe interview experiences
- Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
- Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
- Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
- Adobe New Grad MTS Interview Questions: 7 Experiences
- Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)
- Adobe Product Intern Interviews: 15 Experiences (Part 3 of 4)