Skip to content

Latest commit

 

History

History
43 lines (26 loc) · 912 Bytes

0079.word-search.md

File metadata and controls

43 lines (26 loc) · 912 Bytes

0079.Word-Search

Description

Given a 2D board and a word, find if the word exists in the grid.

The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once.

Example:

board =
[
  ['A','B','C','E'],
  ['S','F','C','S'],
  ['A','D','E','E']
]

Given word = "ABCCED", return true.
Given word = "SEE", return true.
Given word = "ABCB", return false.

Tags: DFS

题意

在矩阵中按顺序查找,判断是否存在给定字符串

题解

思路1

直接dfs查询,对于给定点的上下左右四个位置判断

结语

如果你同我一样热爱数据结构、算法、LeetCode,可以关注我 GitHub 上的 LeetCode 题解:awesome-golang-algorithm