#C12984. Reverse List Without Built-in Methods
Reverse List Without Built-in Methods
Reverse List Without Built-in Methods
You are given a list of integers. Your task is to reverse the list without using Python's built-in reverse()
method or slicing. You should implement the reversal by swapping elements iteratively.
Note: The input will be provided in the following format. First, an integer n specifies the number of elements in the list. The next line contains n space-separated integers. The output should be the reversed list, with the integers separated by a single space.
For example, if the input is:
5 1 2 3 4 5
Then the output should be:
5 4 3 2 1
inputFormat
The first line of input contains an integer \( n \) which denotes the number of elements in the list. The second line contains \( n \) integers separated by spaces.
Example:
5 1 2 3 4 5
outputFormat
Output a single line containing the reversed list of integers, separated by a single space.
Example:
5 4 3 2 1## sample
1
42
42
</p>