725. Remove All Occurrences of a Character Recursively

EasyRecursionRecursion

Given a string s and a single character ch, return a new string that is s with every occurrence of ch removed. You must implement the removal recursively. The output string is returned wrapped in double quotes in the test format.

Input: A string s and a single-character string ch, formatted as "s", "c".

Output: Return the resulting string wrapped in double quotes.

Examples

Example 1
Input: "hello", "l"
Output: "heo"
Explanation: Both 'l' characters are removed.
Example 2
Input: "banana", "a"
Output: "bnn"
Explanation: All three 'a' characters removed.
Example 3
Input: "abc", "z"
Output: "abc"
Explanation: 'z' does not appear; string is unchanged.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →