From f380954c39ad90a39cae4c493224b56ef6d6d225 Mon Sep 17 00:00:00 2001 From: Daniel Zayas Date: Mon, 29 Apr 2024 09:45:13 -0700 Subject: [PATCH 1/2] suggested changes to LC 2677 chunk array --- prob-testing.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/prob-testing.js b/prob-testing.js index 61ff3b4..6362296 100644 --- a/prob-testing.js +++ b/prob-testing.js @@ -1,5 +1,23 @@ // LC 2677 - Chunk Array -- S: O(), T: O() +/* +Nice work so far! + +I would think about this problem in two parts: + +(1) How do I create one of the chunks? +const chunk = function (arr, size, startIndex) {} +// If start_index is out of bounds, return an empty array +// Otherwise return a new non-empty array of the chuck of elements starting at startIndex +// Note that the new array may have a length less than `size` + +(2) How do I use (1) to create the final chunked array output? +const chunk = function (arr, size) {} +// initialize a startIndex at 0 and an outputArray +// while I still have more chucks to add to the outputArray +// create a chunk, add it to outputArray, and update startIndex +*/ + /** * @param {Array} arr * @param {number} size From 80d7aa3d188f74321e8b6d64ff4b736dbd0103ab Mon Sep 17 00:00:00 2001 From: Daniel Zayas Date: Mon, 29 Apr 2024 09:54:14 -0700 Subject: [PATCH 2/2] update suggestions --- prob-testing.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/prob-testing.js b/prob-testing.js index 6362296..8f22285 100644 --- a/prob-testing.js +++ b/prob-testing.js @@ -6,7 +6,7 @@ Nice work so far! I would think about this problem in two parts: (1) How do I create one of the chunks? -const chunk = function (arr, size, startIndex) {} +const createOneChunk = function (arr, size, startIndex) {} // If start_index is out of bounds, return an empty array // Otherwise return a new non-empty array of the chuck of elements starting at startIndex // Note that the new array may have a length less than `size` @@ -15,7 +15,9 @@ const chunk = function (arr, size, startIndex) {} const chunk = function (arr, size) {} // initialize a startIndex at 0 and an outputArray // while I still have more chucks to add to the outputArray -// create a chunk, add it to outputArray, and update startIndex +// create a chunk (use createOneChunk), +// add it to outputArray, +// and update startIndex */ /**