Answers for "transpose an array in javascript"

2

transpose an array in javascript

array[0].map((_, colIndex) => array.map(row => row[colIndex]));
Posted by: Guest on July-02-2020
0

transpose of the matrix in javascript

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
    }
}
Posted by: Guest on June-24-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language