723. Recursive String Length

EasyRecursionRecursion

Given a string s, return its length (number of characters) using recursion. You must not use any built-in length/size function on the string — count characters by walking the string recursively.

Input: A string s enclosed in double quotes in the raw test format.

Output: Return an integer equal to the length of the string.

Examples

Example 1
Input: "hello"
Output: 5
Explanation: Five characters: h, e, l, l, o.
Example 2
Input: ""
Output: 0
Explanation: Empty string has length 0.
Example 3
Input: "a"
Output: 1
Explanation: Single character.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →