Dynamic Array
You are given an integer n.
Implement a function dynamicArray that performs the following tasks:
- Dynamically allocates an integer array of size n.
- Takes the next n integers as input and stores them in the dynamically allocated array.
- Returns the pointer to the created dynamic array.
Example 1:
Input: n = 5, nums = [3, 2, 6, 1, 0]
Output: 3 2 6 1 0
Example 2:
Input: n = 4, nums = [-10, 9, 12, -50]
Output: -10 9 12 -50
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= n <= 100
- -100 <= nums[i] <= 100