Why my code failed
my idea is to traverse just like number of island but make sure only make turn at most once. where is the bug? \nfailed at:\n[[899,727,165,249,531,300,542,890],
my idea is to traverse just like number of island but make sure only make turn at most once. where is the bug? \nfailed at:\n[[899,727,165,249,531,300,542,890],[981,587,565,943,875,498,582,672],[106,902,524,725,699,778,365,220]]\n```\nclass Solution {\n    int res = 0;\n    public int maxTrailingZeros(int[][] grid) {\n        \n        for(int i=0;i<grid.length;i++){\n            for(int j=0;j<grid[0].length;j++){\n                    helper(grid, i, j, 0, 1);\n            }\n        }  \n        return res;\n    }\n    \n    public void helper(int[][] grid, int i, int j, int count, int current){\n        if(i>=grid.length || i < 0 || j<0 || j >=grid[0].length ){\n            while(current>=10 && current%10==0){\n                current = current/10;\n                count++;\n            }\n            res = Math.max(res, count);\n            return;\n        }\n        else{\n            current = current*grid[i][j];\n            while(current%10==0){\n                current = current/10;\n                count++;\n            }\n            toLeft(grid, i, j-1, count, current);\n            toRight(grid, i, j+1, count, current);\n            helper(grid, i+1, j, count, current);\n        }\n    }\n    \n    public void toLeft(int[][] grid, int i, int j, int count, int current){\n        if(i>=grid.length || i < 0 || j<0 || j >=grid[0].length ){\n            while(current >= 10 && current%10==0){\n                current = current/10;\n                count++;\n            }\n            res = Math.max(res, count);\n            return;\n        }\n        else{\n            current = current*grid[i][j];\n            while(current%10==0){\n                current = current/10;\n                count++;\n            }\n            toLeft(grid, i, j-1, count, current);\n            // toRight(grid, i, j+1, count, visited, current);\n            // helper(grid, i+1, j, count, visited, current);\n        }\n    }\n    \n    public void toRight(int[][] grid, int i, int j, int count, int current){\n        if(i>=grid.length || i < 0 || j<0 || j >=grid[0].length ){\n            while(current>=10 && current%10==0){\n                current = current/10;\n                count++;\n            }\n            res = Math.max(res, count);\n            return;\n        }\n        else{\n            current = current*grid[i][j];\n            while(current%10==0){\n                current = current/10;\n                count++;\n            }\n            // toLeft(grid, i, j-1, count, visited, current);\n            toRight(grid, i, j+1, count, current);\n            // helper(grid, i+1, j, count, visited, current);\n        }\n    }\n    \n}\n```
[]