2503. Maximum Number of Points From Grid Queries #27
Unanswered
IamShiwangi
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
2503. Maximum Number of Points From Grid Queries
Problem Statement
You are given an
m x ninteger matrixgridand an arrayqueriesof sizek.Find an array
answerof sizeksuch that for each integerqueries[i], you start in the top-left cell of the matrix and repeat the following process:queries[i]is strictly greater than the value of the current cell, then:After processing each query,
answer[i]is the maximum number of points you can collect.Return the resulting array
answer.Example 1
Input:
Output:
Explanation:
For each query:
5cells.8cells.1cell.Example 2
Input:
Output:
Explanation:
Constraints
m == grid.lengthn == grid[i].length2 <= m, n <= 10004 <= m * n <= 10⁵k == queries.length1 <= k <= 10⁴1 <= grid[i][j], queries[i] <= 10⁶Discussion
Approach 1: Min-Heap + BFS (Optimized Approach)
answer.Time Complexity:
Space Complexity:
🔥 Optimized Solution Using Python
🎯 How to Contribute
📂 File Structure
🔥 Want to Participate?
🔗 Useful Links
💡 Let's learn, code, and grow together! 🚀
Beta Was this translation helpful? Give feedback.
All reactions