719. Linked List - Reverse a linked list (iterative, data)

0

Medium

Implement an iterative algorithm to reverse the data of a linked list's nodes.

Input Format

N represents the number of nodes in the linked list. The next line contains N space-separated numbers representing the content of the linked list.

Output Format

The reversed linked list is represented by N space-separated numbers, showing the content of the reversed linked list.

Example

Input

5 10 20 30 40 50

Output

50 40 30 20 10

Constraints

None
Loading...

View Submissions

Console