Transpose sebuah array di JavaScript
array[0].map((_, colIndex) => array.map(row => row[colIndex]));
Combative Cod
array[0].map((_, colIndex) => array.map(row => row[colIndex]));
transpose = m => m[0].map((x,i) => m.map(x => x[i]))
class Solution {
solve(matrix) {
let arr=[];
for(let i=0;i<matrix.length;i++){
arr.push([])
for(let j=0;j<matrix.length;j++){
arr[i].push(matrix[j][i])
}
}
return arr
}
}