Rotate Image Problem & Solution

See the rotate image problem on LeetCode.

C++ Solution

#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#pragma GCC ivdep

static const int _=[]{ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);return 0;}();

class Solution {
public:
  void rotate(vector<vector<int>>& matrix) {
    reverse(matrix.begin(), matrix.end());

    for (int i = 0; i < matrix.size(); ++i) {
      for (int j = i + 1; j < matrix[i].size(); ++j) {
        swap(matrix[i][j], matrix[j][i]);
      }
    }
  }
};

Start Here

Many paths, there are. Follow yours, you must.