Algorithm · ByteDance · Hard
Requirements You are given a two-dimensional integer grid. Determine the maximum number of cells in a zigzag path. The path may begin at any cell, and each move must go to a neighboring cell sharing an edge: up, down, left, or right. Comparisons between successive cell values must alternate strictly. The sequence must follow either: grid[a] grid[c] grid[b] grid[d]... Thus, an increase must be followed by a decrease, and a decrease must be followed by an increase. Two equal…
Checking your access…