You are given a string s. Your task is to reverse the string using recursion only and return the reversed string. You are not allowed to use loops or built-in reverse functions.
Example 1
Input: s = "hello"
Output: "olleh"
Explanation: The string is reversed using recursion.
Example 2
Input: s = "abcd"
Output: "dcba"
Explanation: The characters appear in reverse order.
Example 3
Input: s = "z"
Output: "z"
Explanation: A single character remains the same after reversing.
Sign in to write, run, and submit your solution against the full test suite.