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 challengesLight Switch Grid

Gamified challenge · Bitmask search

Light Switch Grid

grid[r][c] is 1 if the light at row r, column c is on and 0 if it's off. Pressing a cell toggles that light and its up to four neighbours (up, down, left, right); lights off the edge are ignored. Grids are at most 5 × 5, and every puzzle can be solved.

Write presses(grid) that returns a list of presses [row, col] which, applied in order, switch every light off. For [[0,1,0],[1,1,1],[0,1,0]], [[1, 1]] works. Pressing a cell twice cancels out, and order doesn't matter, so any set of presses that ends with all lights off passes. A dark grid needs [].

Hint: once you've decided the top row, every other press is forced.

Sign in to play Light Switch Grid

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