12. Gold Mine Problem
β GFG solution to the Gold Mine Problem: find maximum gold collection path from left to right using dynamic programming optimization. π
π§© Problem Description
π Examples
Example 1
Input: mat[][] = [[1, 3, 3], [2, 1, 4], [0, 6, 4]]
Output: 12
Explanation: The path is (1, 0) -> (2, 1) -> (2, 2). Total gold collected is 2 + 6 + 4 = 12.Example 2
Input: mat[][] = [[1, 3, 1, 5], [2, 2, 4, 1], [5, 0, 2, 3], [0, 6, 1, 2]]
Output: 16
Explanation: The path is (2, 0) -> (3, 1) -> (2, 2) -> (2, 3) or (2, 0) -> (1, 1) -> (1, 2) -> (0, 3).
Total gold collected is (5 + 6 + 2 + 3) or (5 + 2 + 4 + 5) = 16.Example 3
π Constraints
β
My Approach
Bottom-Up Dynamic Programming
π Time and Auxiliary Space Complexity
π§βπ» Code (C++)
π§βπ» Code (Java)
π Code (Python)
π§ Contribution and Support
πVisitor Count
Last updated