// Determine if a string has all-unique characters. #define CATCH_CONFIG_MAIN #include #include #include std::string urlify(std::string orig, int length) { // Start writing at the back of the string. auto write = orig.end(); for (auto read = orig.begin() + length; read != orig.begin();) { read--; if (*read == ' ') { *--write = '0'; *--write = '2'; *--write = '%'; } else { *--write = *read; } } return std::string(write, orig.end()); } TEST_CASE("cc13", "urlify") { REQUIRE(urlify("Mr John Smith ", 13) == "Mr%20John%20Smith"); }