Sort by

recency

|

2041 Discussions

|

  • + 0 comments

    n = int(input()) arr = list(map(int, input().split())) print(*arr[::-1])

  • + 0 comments

    C#

    class Solution
    {
        public static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine().Trim());
    
            List<int> arr = Console.ReadLine().TrimEnd().Split(' ').ToList().Select(arrTemp => Convert.ToInt32(arrTemp)).ToList();
        arr.Reverse();
        Console.WriteLine(string.Join(" ",arr));
        }
    }
    
  • + 0 comments
    arr = list(map(int, input().rstrip().split()))
    print(*arr[::-1], sep= ' ')
    
  • + 0 comments

    solved in JAVA, if this code can be optimized kindly explain

    List ar = new ArrayList(500);

            for(int j=arr.size()-1;j>=0;j--)
            {
                ar.add(arr.get(j));
            }
    
        for(int i:ar)
        {
            System.out.print(i+" ");
        }
    
  • + 0 comments

    what is the issue with this ?

             // Scanner scanner = new Scanner(System.in); 
        // int n = scanner.nextInt();
        // int array1[] = new int[n];
        // for(i=0;i<n;i++){
        //     array1[i] = scanner.nextInt();
        // }
        // for(j=(n-1); j>=0 ; j--){
        //     System.out.println(array1[j]);
        //     for(j=n-1;j>0;j--){
        //         System.out.print(" ");
        //     }
        // }