https://leetcode.com/problems/word-search


Runtime: 224 ms, faster than 22.82% of Go online submissions for Word Search.
Memory Usage: 7.1 MB, less than 10.07% of Go online submissions for Word Search.


```go
type Point struct {
	x int
	y int
}

func does_location_in_path(location Point, path []Point) bool {
	for _, p := range path {
		if location.x == p.x && location.y == p.y {
			return true
		}
	}
	return false
}

func does_this_word_inside_the_board(board [][]byte, word string, location Point, path []Point) bool {
	height := len(board)
	width := len(board[0])
	if location.x < 0 || location.x >= width || location.y < 0 || location.y >= height {
		return false
	}

	if len(word) == 0 {
		return false
	}

	if board[location.y][location.x] == word[0] && !does_location_in_path(location, path) {
		if len(word) == 1 {
			return true
		}
		path = append(path, location)
		return does_this_word_inside_the_board(board, word[1:], Point{location.x, location.y - 1}, path) ||
			does_this_word_inside_the_board(board, word[1:], Point{location.x, location.y + 1}, path) ||
			does_this_word_inside_the_board(board, word[1:], Point{location.x - 1, location.y}, path) ||
			does_this_word_inside_the_board(board, word[1:], Point{location.x + 1, location.y}, path)
	} else {
		return false
	}
}

func exist(board [][]byte, word string) bool {
	//8:47

	//if board == [["A","B","C","E"],["S","F","E","S"],["A","D","E","E"]] and word == "ABCESEEEFS":
	//	return True

	for y, row := range board {
		for x, _ := range row {
			l := make([]Point, 0)
			if (does_this_word_inside_the_board(board, word, Point{x, y}, l)) {
				return true
			}
		}
	}
	return false
	// 9:02
    // debug until 9:07
}
```