GamifiedGamified challengesPracticeRaceLeaderboardPricing

Learn data structures by watching them move, then doing it yourself. Press M anytime to toggle sound.

A product of Amypo Technologies, Coimbatore.

Learn

  • All topics
  • Learning path
  • How it works
  • About dotprep

Practice

  • Practice arena
  • Daily challenge
  • Gamified challenges
  • Race mode
  • Leaderboard

Interview prep

  • Java interview
  • Coding questions
  • Company questions
  • System design
  • Jobs & careers

You

  • Dashboard
  • Settings
  • Pricing
  • Create account

© 2026 dotprep

Content last updated 20 November 2026

GamifiedGamified challengesPracticeRaceLeaderboardPricing
Log inStart free
Gamified challengesCastle Siege

Gamified challenge · DFS from the border

Castle Siege

board is a map where each string is a row of X (your walls) and O (defenders). Defenders that are next to each other up, down, left or right form one group. A group is captured when none of its cells is on the edge of the map: it has no way out.

Write capture(board) that returns the board after the siege: every O in a captured group becomes X; everything else stays the same.

Example: ["XXXX", "XOOX", "XXOX", "XOXX"] → ["XXXX", "XXXX", "XXXX", "XOXX"]. The middle group is sealed in, but the O in the bottom row is on the edge and escapes.

Sign in to play Castle Siege

This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.

Sign in with Google

or log in with email · create an account