Member-only story
Rotate a Matrix by 90 degrees | Coding Interview | Matrix
5 min readJan 18, 2022
I will simplify the solution using some animations. You might encounter this problem during interviews as “Rotate an image,” it has been asked by companies like Bloomberg, Uber, Google, Apple, Microsoft, Facebook, and Amazon.
If you are preparing for an upcoming interview, you may find these system design interview notes helpful.
This article is part of the 30 days preparation plan 🤯. And this is the last matrix-based problem we are going to cover🤩.
Table of Contents
- Description
- Approach 1 (placing the values in their correct positions)
- Code
- Time & Space Complexity
- Approach 2 (Transpose and Reflect)
- Code
- Time & Space Complexity
Description
We are given a square matrix of size n and we want to rotate it by 90 degrees. Since images are matrices where each pixel is an intensity level of…