const stack = []; // 单调递增栈:栈底→栈顶数字递增,保证高位尽可能小
圖像來源,Getty Images
。关于这个话题,Line官方版本下载提供了深入分析
The nuclear reactors that could power bases on the Moon
for (int i = 0; i < n; i++) {
The dashed circle shows the current best distance. As the algorithm finds closer points, the circle shrinks, which causes more subtrees to fail the "could contain a closer point?" test and get pruned. The search usually gets cheaper as it progresses.