In a forest grid, 0 is an impassable cell, 1 is walkable ground, and any value greater than 1 is a tree of that height. Starting at (0,0), you must cut trees in increasing height order, walking 4-directionally (a cut tree becomes ground). Return the minimum total steps to cut all trees, or -1 if some tree is unreachable. The input is JSON {forest}.
Input: JSON {forest}.
Output: Integer — the minimum total steps, or -1.
Input: {"forest":[[1,2,3],[0,0,4],[7,6,5]]}
Output: 6
Explanation: Walk the spiral cutting in order.Input: {"forest":[[1,2,3],[0,0,0],[7,6,5]]}
Output: -1
Explanation: Lower row is unreachable.Input: {"forest":[[2,3,4],[0,0,5],[8,7,6]]}
Output: 6
Explanation: Reachable in order.1<=rows,cols<=50