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

Function reflect

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

Source from the content-addressed store, hash-verified

28 ]);
29
30var reflect = (matrix) => {
31 const rows = matrix.length;
32
33 for (let row = 0; row < rows; row++) {
34 /* Time O(ROWS) */
35 for (let col = 0; col < rows / 2; col++) {
36 /* Time O(COLS) */
37 const reflection = rows - col - 1;
38
39 swap2(matrix, row, col, reflection);
40 }
41 }
42};
43
44var swap2 = (matrix, row, col, reflection) =>
45 ([matrix[row][col], matrix[row][reflection]] = [

Callers 1

rotateFunction · 0.85

Calls 1

swap2Function · 0.85

Tested by

no test coverage detected