Given a 2D grid of characters grid of dimensions m by n, determine if there is a cycle of identical values within the grid.
A cycle is defined as a sequence of cells such that:
The path begins and ends at the same cell.
The length of the sequence is at least
All cells in the sequence contain the same character.
Each consecutive pair of cells in the sequence are adjacent horizontally or vertically.
The sequence does not revisit the cell visited immediately before the current cell.
Return true if grid contains at least one such cycle, and false otherwise.
Constraints:
m grid.length
n grid[i].length
m, n
grid consists only of lowercase English letters.
Given a 2D grid of characters grid of dimensions m by n, determine if there is a cycle of identical values within the grid.
A cycle is defined as a sequence of cells such that:
The path begins and ends at the same cell.
The length of the sequence is at least
All cells in the sequence contain the same character.
Each consecutive pair of cells in the sequence are adjacent horizontally or vertically.
The sequence does not revisit the cell visited immediately before the current cell.
Return true if grid contains at least one such cycle, and false otherwise.
Constraints:
m grid.length
n grid[i].length
m, n
grid consists only of lowercase English letters.