Path with Maximum Gold

In a grid, each cell contains some gold (0 means empty). You can start from any cell with gold and move in four directions. When you collect gold from a cell, it becomes empty (0) and you can never visit it again. Return the maximum gold you can collect.

You cannot visit cells with 0 gold, and you must stop when no more moves are possible.

Examples
Input: [[0,6,0],[5,8,7],[0,9,0]]
Output: 24
Hints

Path with Maximum Gold

In a grid, each cell contains some gold (0 means empty). You can start from any cell with gold and move in four directions. When you collect gold from a cell, it becomes empty (0) and you can never visit it again. Return the maximum gold you can collect.