Skip to content
We areTOP 1%

Beautiful Matrix

EasyRating 800CodeforcesMatrix (2-D Arrays)
Solve on Codeforces(opens in a new tab)
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews
Approach hintTry it first, then reveal

Each swap of adjacent rows or columns moves the 1 by one step in that direction, so think of the answer as a distance between two cells on the grid.

More in Matrix (2-D Arrays)

Matrix (2-D Arrays) questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1Matrix Diagonal SumLeetCodeEasy Solve Matrix Diagonal Sum on LeetCode (opens in a new tab)
2Beautiful MatrixCodeforcesEasy 800Solve Beautiful Matrix on Codeforces (opens in a new tab)
3Transpose MatrixLeetCodeEasy Solve Transpose Matrix on LeetCode (opens in a new tab)
4Target PracticeCodeforcesEasy 800Solve Target Practice on Codeforces (opens in a new tab)
5Pascal's TriangleLeetCodeEasy Solve Pascal's Triangle on LeetCode (opens in a new tab)
6Lights OutCodeforcesEasy 900Solve Lights Out on Codeforces (opens in a new tab)
7Set Matrix ZeroesLeetCodeMedium Solve Set Matrix Zeroes on LeetCode (opens in a new tab)
8Valid SudokuLeetCodeMedium Solve Valid Sudoku on LeetCode (opens in a new tab)
9Rotate ImageLeetCodeMedium Solve Rotate Image on LeetCode (opens in a new tab)
10Spiral MatrixLeetCodeMedium Solve Spiral Matrix on LeetCode (opens in a new tab)

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account