MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / transpose

Function transpose

javascript/0048-rotate-image.js:12–22  ·  view source on GitHub ↗
(matrix)

Source from the content-addressed store, hash-verified

10};
11
12var transpose = (matrix) => {
13 const rows = matrix.length;
14
15 for (let row = 0; row < rows; row++) {
16 /* Time O(ROWS) */
17 for (let col = row + 1; col < rows; col++) {
18 /* Time O(COLS) */
19 swap1(matrix, row, col);
20 }
21 }
22};
23
24var swap1 = (matrix, row, col) =>
25 ([matrix[row][col], matrix[col][row]] = [

Callers 1

rotateFunction · 0.85

Calls 2

swap1Function · 0.85
swapFunction · 0.70

Tested by

no test coverage detected