Sort by

recency

|

2029 Discussions

|

  • + 0 comments

    Python3:

    if __name__ == '__main__':
        n = int(input().strip())
    
        arr = list(map(int, input().rstrip().split()))
        print(*reversed(arr), sep=' ')
    
  • + 0 comments

    Python Code: simply use * to unpack the list when printing.

    arr = list(map(int, input().rstrip().split()))

    print(*list(reversed(arr)))

  • + 0 comments

    Python code-

    #!/bin/python3
    
    import math
    import os
    import random
    import re
    import sys
    
    if __name__ == '__main__':
        n = int(input().strip())
    
        arr = list(map(int, input().rstrip().split()))
    l= len(arr)
    if l in range(1,1001):
        for i in range(l-1, -1, -1):
            if arr[i] in range(1,10001):
                print (arr[i], end=' ')
    
  • + 0 comments

    Javascript Solution:

    const arrrev = arr.reverse().join(" ")
     console.log(arrrev)
    
  • + 0 comments
    public class Solution {
        public static void main(String[] args) {
                Scanner sc = new Scanner(System.in);
    
            int s = sc.nextInt();   // Read the size of the array
            int [] array = new int [s];
    
            for (int a = 0;a < s;a++)          // Reading input values into the array
    
            {
                array [a] = sc.nextInt();
            }
            int pd = s - 1;
            for (int l = pd; l >= 0; l--) {                   // Print the array in reverse order
    
                    System.out.print(array[l] + " ");
                }
               
        }
    }