Question 1 of 4

Reverse Array

Arrays

Reverse the given array and print the values separated by spaces.

Example 1:

Input: arr = [1, 2, 3, 4]

Output: 4 3 2 1

Explanation: Reversing [1, 2, 3, 4] yields [4, 3, 2, 1].

Example 2:

Input: arr = [9]

Output: 9

Example 3:

Input: arr = [5, 0, -1]

Output: -1 0 5

Code

Testcase / Output

Default testcase

arr = [1, 2, 3, 4]

Expected output

4 3 2 1

Returned results

Click Run to execute your code against the testcase.