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 challengesMirror Garden

Gamified challenge · Recursion

Mirror Garden

The garden is a binary tree of bushes, given as tree (a TreeNode root; examples are written in level order with null for a missing bush). It is symmetric if its left half is the mirror image of its right half: same shape flipped left to right, and every bush has the same number as its mirrored partner.

Write isMirror(tree) (Python: is_mirror(tree)) that returns true if the garden is symmetric about the root, false otherwise. An empty garden and a single bush are symmetric.

[1, 2, 2, 3, 4, 4, 3] is symmetric. [1, 2, 2, null, 3, null, 3] is not: both 3s hang on the right of their parents, so the shapes don't mirror.

Sign in to play Mirror Garden

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