mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2026-11-27 22:43:08 +08:00
feat: scaffold monorepo
This commit is contained in:
@@ -1,12 +1,33 @@
|
||||
function matrixTranspose(matrix) {
|
||||
return matrix[0].map((col, i) => matrix.map(row => row[i]));
|
||||
return matrix[0].map((col, i) => matrix.map((row) => row[i]));
|
||||
}
|
||||
|
||||
const deepEqual = require('./deepEqual');
|
||||
|
||||
console.log(deepEqual(matrixTranspose([[1]]), [[1]]));
|
||||
console.log(deepEqual(matrixTranspose([[1, 2]]), [[1], [2]]));
|
||||
console.log(deepEqual(matrixTranspose([[1, 2], [1, 4]]), [[1, 1], [2, 4]]));
|
||||
console.log(
|
||||
deepEqual(matrixTranspose([[1, 2, 3], [4, 5, 6]]), [[1, 4], [2, 5], [3, 6]]),
|
||||
deepEqual(
|
||||
matrixTranspose([
|
||||
[1, 2],
|
||||
[1, 4],
|
||||
]),
|
||||
[
|
||||
[1, 1],
|
||||
[2, 4],
|
||||
],
|
||||
),
|
||||
);
|
||||
console.log(
|
||||
deepEqual(
|
||||
matrixTranspose([
|
||||
[1, 2, 3],
|
||||
[4, 5, 6],
|
||||
]),
|
||||
[
|
||||
[1, 4],
|
||||
[2, 5],
|
||||
[3, 6],
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user