JavaScript Solution O(n^2)


  • 0
    O
    var rotate = function(matrix) {
      let j = 0, temp=[], len = matrix.length;
    
      while(j<len){
        for(let i=len-1;i>=0;i--){
          temp.push(matrix[i][j])
        }
        matrix.push(temp);
        j++;
        temp = []
      }
      matrix.splice(0, len)
    };
    

Log in to reply
 

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