Learn
Exam

Reversing an Array

Difficulty
STARTER

Problem

Given an array numbers consisting of natural numbers, write a function solution that returns the reversed version of numbers.


Constraints

  • Each element in numbers is a natural number not exceeding 20.
  • numbers is not empty, and its length does not exceed 50.

Test Case

Test Case Number numbers return
1 [1] [1]
2 [1, 2, 3, 4, 5] [5, 4, 3, 2, 1]
3 [4, 5, 6] [6, 5, 4]

Explanation for Test Case 1

  • For numbers = [1], reversing the array results in [1].

Explanation for Test Case 2

  • For numbers = [1, 2, 3, 4, 5], reversing the array results in [5, 4, 3, 2, 1].

Explanation for Test Case 3

  • For numbers = [4, 5, 6], reversing the array results in [6, 5, 4].