Given the two lines, the base and delete, return the version of the base line where all instances of the delete line were deleted (not case sensitive). You can assume that the delete line has a length of 1 or more. Delete only non-overlapping instances, so with "xxx" deleting "xx" leaves "x".
withoutString("Hello there", "llo") โ "He there"
withoutString("Hello there", "e") โ "Hllo thr"
withoutString("Hello there", "x") โ "Hello there"
Why I can not use this code:
public String withoutString(String base, String remove)
{
base.replace(remove, "");
return base;
}
source
share