Back to problems

Design Connect Four

Object-Oriented Programming · Airbnb · Medium

One‑Pass Directional Scan The fundamental operation in Connect Four is recognizing when four consecutive discs of the same player appear along any straight line. A straightforward way to achieve this is to, after each move, examine all four possible directions starting from the newly placed disc and see if any forms a winning chain. The placed disc acts as a pivot; we extend outward in both directions along a given axis, counting contiguous discs belonging to the current…

Checking your access…