You are implementing a board game where you are given a size N x M for the board, where N is the number of rows and M is the number of columns.
In this board game you are playing with some fixed size lego pieces, where each player places 1 piece on the board every turn until no more piece can fit onto the board, and the last player to move wins.
The problem is to implement a method for making a move on this board, placing a piece wherever there is space available, and returns a boolean indicating whether or not the player that has just made the move has won.
Follow up question: The method should also find if there is any move that can be made that will make it so that the next player is unable to place a piece anywhere on the board in their next turn, and make that move.
You choose how to represent the board and lego pieces in the problem, during my interview I chose to use a 2D array of characters for the board, where each X indicates occupied and O indicates spot is free and lego piece has dimension 2 X 4.
Simple example (small board for demonstration purposes, board length = 4 x 4, lego piece length = 2 x 4):
Empty Board:
O O O O
O O O O
O O O O
O O O O
Board after player 1 makes move, placing lego piece at Middle columns:
O X X O
O X X O
O X X O
O X X O
At this point, player 2 can't make a move and player 1 wins
I am only able to implement brute force approach.
Please let me know if anyone thinks that it is possible to solve this in 45 min interview typically in phone screen round with an optimised approach
Can you guys upvote this question so that it will reach to maximum audience and we can get some solution for it.