Can Some Quarter Turn Make One Map Tile Match Another

Last updated: November 29, 2026

Quick Overview

Given two n x n binary map tiles, return whether rotating the first tile by 0, 90, 180 or 270 degrees clockwise makes it identical to the second.

Google
Coding & Algorithms
Software Engineer
Google
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Easy

0

0

0 solved


Given two n x n binary map tiles, return whether rotating the first tile by 0, 90, 180 or 270 degrees clockwise makes it identical to the second.

A short Google online assessment style check for map tile deduplication. The interviewer looks for correct rotation index formulas and an early exit, and may ask how to compare without allocating rotated copies.

What the Interviewer Expects
  • Writes the 90-degree clockwise rotation correctly
  • Tries all four rotations including zero
  • Exits early on the first match
  • Offers a copy-free comparison using index formulas
  • States O(n^2) time
Key Topics to Cover
Matrix Rotation
Index Formulas
Equality Check
Canonical Forms
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Also allow mirror images.
  • Group a million tiles into classes that are equal up to rotation.
  • Compare without allocating any rotated copies.
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input: a, b, both n x n.
  • Output: True if any of the four rotations of a equals b....
High-Level Design

A clockwise rotation maps a[i][j] to position (j, n-1-i), equivalently rot[i][j] = a[n-1-j][i]. Checking each rotation directly by formula avoids copies:

  • 0 degrees: a[i][j] == b[i][j]
  • 90: ...

Submit Your Answer
Markdown supported