OxToTiger
SRM 823 · 2022-02-01 · by misof
Problem Statement
To celebrate the Lunar New Year that starts the Year of the Tiger, the problems in this set feature tigers.
I want to send my friends a message with best wishes for the upcoming year of the tiger. As I'm lazy, I just found a similar message I sent last year and now I just need to update it.
You are given the
Make sure to only replace whole words. Do not replace "ox" if it occurs as a part of a longer contiguous block of letters.
Constraints
- message will contain between 0 and 100 characters, inclusive.
- Each character of message will be a lowercase English letter ('a'-'z') or a space (' ').
"ox" Returns: "tiger"
"fox" Returns: "fox"
Don't replace "ox" if it isn't a stand-alone word.
" ox " Returns: " tiger "
This message starts with one space and ends with two spaces. All characters other than the "ox" you are replacing must be preserved exactly.
"the ox the ox the ox and the fox in the box" Returns: "the tiger the tiger the tiger and the fox in the box"
Remember to replace all occurrences of the word "ox", not just some of them.
"the plural of ox is oxen" Returns: "the plural of tiger is oxen"
We aren't doing anything smart, we are literally just replacing "ox" with "tiger". The "oxen" should remain unchanged.
Submissions are judged against all 41 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class OxToTiger with a public method string rewrite(string message) · 41 test cases · 2 s / 256 MB per case