Problem
Given a string word and a substring target, write a function solution that returns the result of removing target from word.
Note that target appears only once in word.
Constraints
- The length of
wordis between 1 and 100 inclusive. - The length of
targetis between 1 and the length ofwordinclusive. wordandtargetconsist only of lowercase English letters.
Test Case
| Test Case Number | word | target | return |
|---|---|---|---|
| 1 | "banana" | "b" | "anana" |
| 2 | "abcdef" | "cde" | "abf" |
| 3 | "hello world" | " " | "helloworld" |
Explanation for Test Case 1
- When
word = "banana"andtarget = "b", removing"b"results in"anana".
Explanation for Test Case 2
- When
word = "abcdef"andtarget = "cde", removing"cde"results in"abf".
Explanation for Test Case 3
- When
word = "hello world"andtarget = " "(space), removing" "results in"helloworld".