share my solution, is that right?


  • 0
    K

    class Solution {
    public:
    void rotate(vector<vector<int>>& matrix) {
    int r = matrix.size();
    int c = matrix[0].size();
    for (int i = 0; i < r; ++i) {
    for (int j = i; j < c; ++j) {
    swap(matrix[i][j], matrix[j][i]);
    }
    }
    for(int n = 0; n < r; ++n) {
    for (int m = 0; m < c/2; ++m) {
    swap(matrix[n][m], matrix[n][c-m-1]);
    }
    }
    }
    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.