HackerRank Java Arrays- DS



https://www.hackerrank.com/challenges/arrays-ds/problem



  1. public class Solution {
  2. public static void main(String[] args) {
  3. /* Save input */
  4. Scanner scan = new Scanner(System.in);
  5. int size = scan.nextInt();
  6. int [] array = new int[size];
  7. for (int i = 0; i < size; i++) {
  8. array[i] = scan.nextInt();
  9. }
  10. scan.close();
  11. /* Print elements in reverse order */
  12. for (int i = size - 1; i >= 0; i--) {
  13. System.out.print(array[i] + " ");
  14. }
  15. }
  16. }

download android app