My solution


  • 0
    Y
    int n = matrix[0].size();
    for(int i = 0; i < n; i++)
        for(int j = i; j < n; j++)
            swap(matrix[i][j], matrix[j][i]);
    for(int i = 0; i < n; i++)
        reverse(matrix[i].begin(), matrix[i].end());
    

Log in to reply
 

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