Facebook | phone screen
Anonymous User
10384

Desing a Connect Four game. Just like Leet 348, you need to implement a int move(int col, int player) which can decide the winner efficiently. Note that each player only needs to drop the ball into a column and if any of players gets 4 of their balls in a row, column, diagonal or antidiagonal, they are the winner.

What's the most efficient way of solving this problem? The bruteforce way is kinda obvious (doing for loop checks - O(4)) but anyone can think of a better approach?

Comments (10)