Closest Pair of Points
Updated
Problem statement
Given two equal-length integer arrays xCoordinates and yCoordinates, entry i represents the point (xCoordinates[i], yCoordinates[i]). Return the minimum squared Euclidean distance between any two distinct entries.
For points (x1, y1) and (x2, y2), their squared distance is (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2). Two entries may have identical coordinates, in which case their squared distance is 0.
Function
closestPairSquaredDistance(xCoordinates: int[], yCoordinates: int[]) → longExamples
Example 1
xCoordinates = [0,3]yCoordinates = [0,4]return = 25There is one pair, and its squared distance is 3 * 3 + 4 * 4 = 25.
Example 2
xCoordinates = [0,1,2]yCoordinates = [0,1,2]return = 2Each adjacent diagonal pair has squared distance 1 * 1 + 1 * 1 = 2, which is minimal.
Example 3
xCoordinates = [5,5,9]yCoordinates = [-2,-2,9]return = 0The first two entries have identical coordinates, so the minimum squared distance is 0.
Constraints
2 <= xCoordinates.length = yCoordinates.length <= 100000.-10^9 <= xCoordinates[i], yCoordinates[i] <= 10^9.- Different entries may represent the same coordinates.
More Citadel Phone Screen questions
- Speed Up a Slow FunctionOA · PHONE SCREEN · Seen Nov 2026
- Portfolio Tickers with Constant-Time Random PickPHONE SCREEN · Seen Nov 2026
- Square Root FunctionPHONE SCREEN · Seen Oct 2026
- Reachable Transfer PositionsPHONE SCREEN · Seen Oct 2026
- Spreadsheet Formula DependenciesPHONE SCREEN · Seen Oct 2026
- Currency Arbitrage CyclePHONE SCREEN · Seen Sep 2026
- Order Book with Cancel by Order IDPHONE SCREEN · Seen Sep 2026
- Smart Queue of Latest PricesPHONE SCREEN · Seen Sep 2026
- Merge Price-Delta FeedsPHONE SCREEN · Seen Sep 2026
- Reconcile Unmatched Trades with Timestamp TolerancePHONE SCREEN · Seen Sep 2026
Similar questions at other companies
- Minimum Euclidean Distance Between PointsLuma AI · OALuma AI interview questions
- Maximum Visible DronesAnduril · PHONE SCREENAnduril interview questions
- Count Inversions With Merge SortAdobe · PHONE SCREENAdobe interview questions
- Find All Points Within a RadiusGoogle · PHONE SCREENGoogle interview questions
- Locate Vehicles with Square QueriesApplied Intuition · PHONE SCREENApplied Intuition interview questions
- K Closest Points to the OriginWhatNot · PHONE SCREENWhatNot interview questions
- K Closest Points to the OriginSambaNova Systems · PHONE SCREENSambaNova Systems interview questions
- Maximum Points in a Perimeter-Bounded RectangleAmerican Express · OAAmerican Express interview questions
- Best Meeting PointWalmart · OAWalmart interview questions
- Temporal AnomaliesInMobi · OAInMobi interview questions
Citadel interview experiences
- Citadel Securities Quant Researcher Intern Loop: 1 Experience
- Citadel Securities Research Engineer Interview: 1 Experience
- Citadel Securities SWE Intern First Round: 2 Experiences
- Citadel Securities Experienced SWE Interviews: 1 Experience
- Citadel SWE Intern Later Rounds and Superday: 13 Experiences
- Citadel SWE Intern First-Round Questions: 20 Experiences