Sort by

recency

|

2057 Discussions

|

  • + 0 comments

    Python Solution:

    print(*arr[::-1])
    
  • + 0 comments

    just started exception handeling in java , and tried to understand .

  • + 0 comments

    Simple and easy to understand-

    public class Solution { public static void main(String[] args) throws IOException {

        //import scanner that is scan
    
            Scanner scan = new Scanner(System.in);
    
                        //input n
    
            int n = scan.nextInt();
    
                        //array initialize
    
        int[] arr = new int[n];
    
                // for loop for array
    
        for(int i=0; i<n; i++){
            arr[i] = scan.nextInt();
        }    
    
                // for loop for reversing which will print the input in reversed order
    
    
        for(int i = n-1; i>=0;i--){
            System.out.print(arr[i]+ " ");
        }
    
        scan.close();
    }
    

    }****

  • + 0 comments

    Logic in Java for reversing an array

      Scanner scan = new Scanner(System.in);
             int N = scan.nextInt();
           int[] arr =  new int[N];
            for(int i=0;i<arr.length;i++)
            {
                arr[i] = scan.nextInt();
            }
            for(int i = arr.length-1;i>=0;i--)
            {
                System.out.print(arr[i]+" ");
            }
    
           
    
            scan.close();
    
  • + 0 comments

    !/bin/python3

    import os import math import re import random import sys

    n = int(input())

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

    myList.reverse()

    print(*myList)