Search
⌘K

Leetcode 2146. K Highest Ranked Items Within a Price Range

Run a BFS from the start to get shortest-path distances to reachable cells (0 = wall), collect cells whose value is within [low, high], and return up to k positions sorted by increasing distance, then increasing price, then smaller row, then smaller column.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.