Facebook | phone screen
Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2021-05-10Added By Anonymous
Source: Link
Company: Meta (Facebook)
Role: e3, e4
Interview Stage: Phone Screen
Location: unknown
Year: unknown
Original Post Content:
Design 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 brute-force way is kinda obvious (doing for loop checks - O(4)) but anyone can think of a better approach?