โ† Adobe questions

Dynamically allocate a k-dimensional array

Filed under Adobe

Free read 1 of 3

Understand the target language (C/C++ vs Python/Java) and how multidimensional bracket indexing is expected to behave.

The question

Write a function that takes dimension sizes as parameters and dynamically allocates memory for an arbitrary k-dimensional array so that elements can be accessed using standard multi-dimensional bracket notation.

Constraints

  • Dimensions list contains positive integers.
  • Memory allocation must be contiguous or properly managed via pointer arrays to avoid leaks.
  • Total size should not exceed memory limits.

Examples

Input
dims = [2, 3]
Output
A 2x3 allocated array accessible as arr[i][j]
Why
Allocates a 2D array with 2 rows and 3 columns.

Approach

  1. Understand the target language (C/C++ vs Python/Java) and how multidimensional bracket indexing is expected to behave.

Tips

  • What they are testing: Test with 1D, 3D, and degenerate dimensions like 1 to ensure pointer indexing holds.
  • Common mistake: Failing to clean up memory correctly, resulting in memory leaks across nested allocations.

Related Adobe questions

Collected from public candidate posts and coding forums. Updated Nov 2026.