The fastest way to check if a move is a winning move in Tic Tac Toe I'm creating a tic tac toe game, there will be two players: X and O. X will be a human, and O is an AI which will always choose the best move to play.   My board is an 11x11 board and the winning condition is 5 in a row. 

How do I know if a board is at end state (where one player has won)? For the 3x3 board, you can do it easily with just a few steps. But for the larger board (11x11) and the winning condition is smaller than the dimension, it's way more complex. The best solution I have found is to check for each n x n (n is the winning condition) square for a winner.  But that seems slow.

So here is my question: if you know the last move of a player, can you use that position to check if that player wins without checking every n x n square in the board?
Yes, you can do this more efficiently.  If you have a board position and the last move made to get to that position, you can check whether the board position is an end state using the following insight:

The previous board position wasn't an end state.  Thus, if the board is an end state, that can only happen because there's a 5-in-a-row that includes the square where the last move occurred.

So, if the last move was in square $s$, check whether there's a 5-in-a-row that includes square $s$.  There are only 4 directions to check (horizontal, vertical, and both diagonals), and you can check each direction efficiently.