Practice Maximum Trailing Zeros in a Cornered Path
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given a 2D integer array grid of size m x n, where each cell contains a positive integer. A cornered path is defined as a set of adjacent cells with at most one turn. More specifically, the path should exclusively move either horizontally or vertically up to the turn (if there is one), without returning to a previously visited cell. After the turn, the path will then move exclusively in the alternate direction: move vertically if it moved horizontally, and vice versa, also without returning to a previously visited cell. The product of a path is defined as the product of all the values in the path. Return the maximum number of trailing zeros in the product of a cornered path found in grid.
Source: Maximum Trailing Zeros in a Cornered Path on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
grid = [[23,17,15,3,20],[8,1,20,27,11],[9,4,6,2,21],[40,9,1,10,6],[22,7,4,5,3]]
3
# Example 2
grid = [[4,3,2],[7,6,1],[8,8,8]]
0
Constraints
Related LeetCode Problems
Practice more problems similar to Maximum Trailing Zeros in a Cornered Path.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.