Algorithm · Amazon · Medium
You are given a game board together with one move, described by a board position and the player making it. Put the player's piece at the given position. Then, for each of the eight directions around that position, look for a run of opponent pieces that is bounded on one side by the newly placed piece and on the other side by another piece belonging to the same player. Flip every opponent piece in every such run to the moving player's color. If the move is illegal, return the…