Question : transpose an array in javascript
Answered by : subramanya-g
array[0].map((_, colIndex) => array.map(row => row[colIndex]));
Source : https://stackoverflow.com/questions/17428587/transposing-a-2d-array-in-javascript | Last Update : Thu, 09 Jul 20
Question : javascript transpose array
Answered by : long-lion-49avhn4ttkch
transpose = m => m[0].map((x,i) => m.map(x => x[i]))
Source : https://stackoverflow.com/questions/17428587/transposing-a-2d-array-in-javascript | Last Update : Sat, 02 Oct 21
Question : transpose of the matrix in javascript
Answered by : courageous-caiman-9o99x4dy3nnx
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 }
}
Source : https://stackoverflow.com/questions/17428587/transposing-a-2d-array-in-javascript | Last Update : Wed, 01 Jul 20