#3275
K-th Nearest Obstacle Queries
specialist · 900 · lc medium +31 · 48.9% accepted · 116 likes · top 35%
Description
You are given positive integer k and 2D array queries where each queries[i] = [x, y] places an obstacle at (x, y) with Manhattan distance |x| + |y| from origin. After each query, return the k-th nearest obstacle distance, or -1 if fewer than k exist.
Code
1
2
3