Reverse List

Reverse List

Easy Python Lists 15 views
Explanation Complexity

Problem Statement

Read n integers. Output them in reverse order.

Input Format

First line n. Second line n integers.

Output Format

One line reversed list.

Example

5
1 2 3 4 5
5 4 3 2 1

Constraints

1

Input / Output Format

Input Format
First line n. Second line n integers.
Output Format
One line reversed list.
Constraints
1

Examples

Input:
5 1 2 3 4 5
Output:
5 4 3 2 1

Example Solution (Public)

Python
import sys
p=sys.stdin.read().strip().split()
if not p: sys.exit(0)
n=int(p[0])
a=p[1:1+n]
a.reverse()
sys.stdout.write(' '.join(a))

Official Solution Code

import sys
p=sys.stdin.read().strip().split()
if not p: sys.exit(0)
n=int(p[0])
a=p[1:1+n]
a.reverse()
sys.stdout.write(' '.join(a))
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.