Loading Question...
Started with brief introduction and then follow by this dsa ques
Problem: Maximum Coins in a Grid and Number of Optimal Paths
You are given an N × M grid, where each cell contains a non-negative number of coins. You start at the top-left cell (0, 0) and must reach the bottom-right cell (N-1, M-1).
From any cell, you can move only right or down. Whenever you visit a cell, you collect all the coins present in it, including the starting and destination cells.
Your task is to:
Follow-up: Space Optimization
Can you optimize the space complexity of your solution while maintaining the same time complexity?
Constraints:
Input: 3 3 1 2 3 4 5 1 2 2 6
Output: Maximum coins: 17 Number of optimal paths: 1
Expected Complexity:
Last updated Oct 20, 2026