String Replace

Today’s objective is to write a method that takes a given string and replaces all occurrences of that string with another string and returns the number of replacements made. For instance, given the string “problem of the day” and a replacement value of ” “, the final result would be “problem-of-the-day” with a return value of 3. If your language of choice doesn’t support pass by reference of strings feel free to return multiple values.

-Problem of the Day

Back to top ▴