You are given an array of integers. Your task is to reverse the array using recursion only. You are not allowed to use any loops or built-in reverse functions.
Return the array after reversing all its elements.
Example 1
Input: arr[] = [1 2 3 4 5]
Output: 5 4 3 2 1
Explanation: The order of the elements is reversed.
Example 2
Input: arr[] = [10 20 30 40]
Output: 40 30 20 10
Explanation: The first element becomes last and the last becomes first.
Example 3
Input: arr[] = [7]
Output: 7
Explanation: A single element remains the same after reversing.
Sign in to write, run, and submit your solution against the full test suite.