2 line C++ solution


  • 0
    P
    class Solution {
    public:
        void rotate(vector<vector<int>>& matrix) {
            for(int i=0;i<matrix.size()/2;++i) swap(matrix[i],matrix[matrix.size()-i-1]);
            for(int i=0;i<matrix.size();++i) for(int j=0;j<i;++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.