You are given an integer matrix grid of size m by n and an integer array queries of size k.
For each query queries[i], you start at the top left cell
If the value at gridqueries[i], you cannot visit any cells and earn
Otherwise, you start at cell queries[i].
Each uniquely visited cell adds
Return an array answer of size k where answer[i] is the maximum number of points you can earn for the query queries[i].
Constraints:
m == grid.length
n == grid[i].length
m, n
m * n
k == queries.length
k
grid[i][j], queries[i]
You are given an integer matrix grid of size m by n and an integer array queries of size k.
For each query queries[i], you start at the top left cell
If the value at gridqueries[i], you cannot visit any cells and earn
Otherwise, you start at cell queries[i].
Each uniquely visited cell adds
Return an array answer of size k where answer[i] is the maximum number of points you can earn for the query queries[i].
Constraints:
m == grid.length
n == grid[i].length
m, n
m * n
k == queries.length
k
grid[i][j], queries[i]