Question: Using MATALB and no if statements, write a function called removeMultipleOccurrences that takes a character c and a string str , and returns the result

Using MATALB and no if statements, write a function called removeMultipleOccurrences that takes a character c and a string str , and returns the result of replacing multiple contiguous occurrences of c in str by one occurrence of c in str.

Consider the following examples:

Iin the first example repeated spaces are replaced by a single space.

>> removeMultipleOccurrences(' hello hello hello hello ', ' ')

ans =

hello hello hello hello

In the second example repeated letter l are replaced by a single l.

>> removeMultipleOccurrences(' hello hello hello hello ', 'l')

ans =

helo helo helo helo

And test your function on several inputs.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!