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 challengesPhoto Rotator

Gamified challenge · 2-D index mapping

Photo Rotator

photo is a square n × n grid of pixel values. Turn it 90° clockwise: the left column becomes the top row, the top row becomes the right column, and so on. In other words, the pixel at (r, c) moves to (c, n - 1 - r).

Write rotate(photo) that turns the photo and returns it. Try to do it in place, with O(1) extra memory, then return the same grid. Example: [[1, 2, 3], [4, 5, 6], [7, 8, 9]] → [[7, 4, 1], [8, 5, 2], [9, 6, 3]].

An empty photo [] stays []. Pixel values are any whole numbers.

Sign in to play Photo Rotator

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