Given an array of numbers arr and a positive integer size, split the array into chunks where each chunk has at most size elements. Return the resulting 2D array.
The last chunk may contain fewer than size elements if the array length is not evenly divisible by size.
arr = [1, 2, 3, 4, 5], size = 2[[1, 2], [3, 4], [5]]arr = [1, 2, 3, 4], size = 4[[1, 2, 3, 4]]arr = [1, 2, 3, 4, 5, 6], size = 3[[1, 2, 3], [4, 5, 6]]0 <= arr.length <= 10^41 <= size <= arr.length (when arr is non-empty)arr contains integersRun your code to see results
Use Cmd+Enter to run