Pointer Traversal
You are given:
- An integer n, representing the size of an array
- A pointer p, which points to the first element of an integer array of size n
Your task is to print all the elements of the array using the given pointer.
Note: Do not print an extra space at end after printing all elements, instead move to new line.
Example 1:
Input: n = 5, arr = [1, 2, 3, 4, 5]
Output: 1 2 3 4 5
Example 2:
Input: n = 4, arr = [9, -10, 2, 4]
Output: 9 -10 2 4
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 <= arr[i] <= 100