Approach hintTry it first, then revealHide
A light's final state depends only on the parity of the presses on it and on its side neighbours. Use direction arrays with bounds checks to add up those presses.
More in Matrix (2-D Arrays)
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | Matrix Diagonal Sum | LeetCode | Easy | Solve Matrix Diagonal Sum on LeetCode (opens in a new tab) | |||
| 2 | Beautiful Matrix | Codeforces | Easy 800 | Solve Beautiful Matrix on Codeforces (opens in a new tab) | |||
| 3 | Transpose Matrix | LeetCode | Easy | Solve Transpose Matrix on LeetCode (opens in a new tab) | |||
| 4 | Target Practice | Codeforces | Easy 800 | Solve Target Practice on Codeforces (opens in a new tab) | |||
| 5 | Pascal's Triangle | LeetCode | Easy | Solve Pascal's Triangle on LeetCode (opens in a new tab) | |||
| 6 | Lights Out | Codeforces | Easy 900 | Solve Lights Out on Codeforces (opens in a new tab) | |||
| 7 | Set Matrix Zeroes | LeetCode | Medium | Solve Set Matrix Zeroes on LeetCode (opens in a new tab) | |||
| 8 | Valid Sudoku | LeetCode | Medium | Solve Valid Sudoku on LeetCode (opens in a new tab) | |||
| 9 | Rotate Image | LeetCode | Medium | Solve Rotate Image on LeetCode (opens in a new tab) | |||
| 10 | Spiral Matrix | LeetCode | Medium | Solve Spiral Matrix on LeetCode (opens in a new tab) |