PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Virtu

Implement Connect Four Winner Detection

Last updated: May 5, 2026

Quick Overview

This question evaluates the ability to design and implement game-state logic for a Connect Four-style board, covering board data structures, coordinate and boundary handling, gravity-based token placement, and efficient pattern detection for consecutive tokens in the Coding & Algorithms domain.

  • medium
  • Virtu
  • Coding & Algorithms
  • Data Scientist

Implement Connect Four Winner Detection

Company: Virtu

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Implement a Connect Four-style game engine. The board has 6 rows and 7 columns. Two players alternate turns. On each turn, the current player chooses a column. Because of gravity, the player's token falls to the lowest empty cell in that column. A move is invalid if the chosen column is already full. After each valid move, determine whether the current player has won. A player wins if they have four of their own tokens consecutively in any of the following directions: - Horizontal - Vertical - Diagonal from bottom-left to top-right - Diagonal from top-left to bottom-right Design and implement the core logic for placing a token and checking whether the latest move creates a win. Follow-up questions: 1. How would you support more than two players? 2. How would you optimize the solution if the board were very large?

Quick Answer: This question evaluates the ability to design and implement game-state logic for a Connect Four-style board, covering board data structures, coordinate and boundary handling, gravity-based token placement, and efficient pattern detection for consecutive tokens in the Coding & Algorithms domain.

Virtu logo
Virtu
Jan 22, 2026, 12:00 AM
Data Scientist
Technical Screen
Coding & Algorithms
0
0

Implement a Connect Four-style game engine.

The board has 6 rows and 7 columns. Two players alternate turns. On each turn, the current player chooses a column. Because of gravity, the player's token falls to the lowest empty cell in that column. A move is invalid if the chosen column is already full.

After each valid move, determine whether the current player has won. A player wins if they have four of their own tokens consecutively in any of the following directions:

  • Horizontal
  • Vertical
  • Diagonal from bottom-left to top-right
  • Diagonal from top-left to bottom-right

Design and implement the core logic for placing a token and checking whether the latest move creates a win.

Follow-up questions:

  1. How would you support more than two players?
  2. How would you optimize the solution if the board were very large?

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Virtu•More Data Scientist•Virtu Data Scientist•Virtu Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.