HackerRank 30 days of coding – Day7 ( Array)

TASK : Given an array, A, of integers,N print A’s elements in reverse order as a single line of space-separated numbers.

Sample Input
4
1 4 3 2

Sample Output
2 3 4 1

Solution (Python):

import math
import os
import random
import re
import sys

if __name__ == '__main__':
      n = int(raw_input())
      arr = map(int, raw_input().rstrip().split())
      arr.reverse()
      for i in range(0,len(arr)):
             print arr[i],

Leave a Reply