Leetcode Problem 2022. Convert 1D Array Into 2D Array

2022. Convert 1D Array Into 2D Array

Leetcode Solutions

IterativeD Array Construction

  1. Check if the length of original is equal to m * n. If not, return an empty array.
  2. Initialize an empty list result that will store the 2D array.
  3. Use a loop to iterate through original with a step of n.
  4. In each iteration, slice the original array from the current index to the current index plus n and append this slice to result.
  5. Return the result list.
UML Thumbnail

Direct Element Mapping

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...