Rotate a Matrix

This is my implementation for clockwise rotation

void rotate(vector<vector<char>>& g) {
    int n = g.size();
    for (int i = 0; i < n / 2 + n % 2; i++) {
        for (int j = 0; j < n / 2; j++) {
            int tmp = g[i][j];
            g[i][j] = g[n - 1 - j][i];
            g[n - 1 - j][i] = g[n - 1 - i][n - 1 - j];
            g[n - 1 - i][n - 1 - j] = g[j][n - 1 - i];
            g[j][n - 1 - i] = tmp;
        }
    }
}

Neetcode does like a 2 pointer appraoch https://www.youtube.com/watch?v=fMSJSS7eO1w