Nearest Neighbor
2026/3/9小于 1 分钟
Nearest Neighbor
题面
对 N 个 3D 点,计算每个点的最近邻索引(可用平方欧氏距离,无需开方),写回 indices[i]。
Implementation Requirements
- The solve function signature must remain unchanged
- External libraries are not permitted
- 结果写入
indices
Examples
points=[(0,0,0),(1,0,0),(5,5,5)] → indices=[1,0,1]Constraints
- 1 ≤ N ≤ 100,000;坐标为 float32,范围 [-1000,1000]
- Performance: N = 10,000