Skip to content

Instantly share code, notes, and snippets.

@c7x43t
Created August 5, 2021 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c7x43t/b4dcf257818a2d54a0e11d995e8ec082 to your computer and use it in GitHub Desktop.
Save c7x43t/b4dcf257818a2d54a0e11d995e8ec082 to your computer and use it in GitHub Desktop.
function transpose(matrix){
var n=matrix.length;
var m=matrix[0].length;
var result=new Array(m);
for(var i=0;i<m;i++){
result[i]=new Array(n);
for(var j=0;j<n;j++){
result[i][j]=matrix[j][i];
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment