Javascript Solution, less than 100ms how about 180?270?


  • 0
    T
    var rotate = function(matrix) {
        if(matrix.length == 0 || matrix.length != matrix[0].length){
           return false;
        }
        var res = JSON.parse(JSON.stringify(matrix));
        n = matrix.length;
        for(i=0;i<n;i++){
            for(j=n-1;j>-1;j--){
                matrix[i][n-j-1] = res[j][i];         
            }
        }
        
    };
    

Log in to reply
 

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