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

Function spiral

javascript/0054-spiral-matrix.js:242–251  ·  view source on GitHub ↗
(matrix, order)

Source from the content-addressed store, hash-verified

240};
241
242var spiral = (matrix, order) => {
243 let [row, col, direction, changeDirection] = [0, 0, 0, 0];
244
245 while (changeDirection < 2) {
246 /* Time O(ROWS * COLS) | Ignore Auxilary Spsace O(ROWS * COLS) */
247 [row, col, direction, changeDirection] =
248 /* Time O(ROWS * COLS) | Ignore Auxilary Spsace O(ROWS * COLS) */
249 getPointers(matrix, row, col, direction, changeDirection, order);
250 }
251};
252
253const getPointers = (matrix, row, col, direction, changeDirection, order) => {
254 [row, col, direction, changeDirection] =

Callers 1

spiralOrderFunction · 0.85

Calls 1

getPointersFunction · 0.70

Tested by

no test coverage detected