Read and Print the List

You are given a list nums consisting of N integers. Your task is to read the list and print all its elements in the same order, separated by spaces.

Example 1:

Input:

nums = [10, 20, 30, 40, 50]

Output:

10 20 30 40 50

Explanation:

The given list contains five elements: 10, 20, 30, 40, 50.

Print all the elements in their original order, separated by spaces. Since no modification is required, the output is 10 20 30 40 50.

Example 2:

Input:

nums = [-1, 0, 5, 8]

Output:

-1 0 5 8

Explanation:

The given list contains four elements: -1, 0, 5, 8.

Print each element in its original order, including the negative number -1 and zero. The output is -1 0 5 8.

Now Your Turn!

Pick the correct output for the given input

Input:

nums = [-10, 2, 4, 0]

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
  • -105 <= nums[i] <= 105

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

0
class Solution {
public:
void printList(vector<int>& arr) {
// Write your code here
}
};
Test Case

Input:

Nums