Maximum Number of Points from Grid Queries
CodingPhone ScreenSoftware EngineerReported Jan, 2026
Examples
Example 1:
Input: grid = [[1,2,3],[2,5,7],[3,5,1]], queries = [5,6,2]
Output: [5,8,1]
Example 1:
Input: grid = [[1,2,3],[2,5,7],[3,5,1]], queries = [5,6,2]
Output: [5,8,1]
You are given an integer matrix grid and an array queries. Starting from the top-left cell, you may move in four directions.
For each query value q, count how many cells can be reached using only cells whose value is strictly less than q. Return the answers in the original query order.
2 <= grid.length, grid[i].length <= 10001 <= queries.length <= 10^41 <= grid[i][j], queries[i] <= 10^6Reported as LeetCode 2503 in a software engineer phone screen.