C++ 4ms solution with 7 lines


  • 0
    J
    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]);
        }
    }

Log in to reply
 

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