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.
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
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- 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 ProblemsSample Answer
Requirements
- Input:
a,b, both n x n. - Output:
Trueif any of the four rotations ofaequalsb....
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: ...