If all they expect are passing test cases, then just use canned values in your code to make the tests pass. This is way more performant and even more efficient to write.
As I said, some of the test cases for this particular problem can be strings up to 100,000 characters long. Do you really think it's faster to solve those by hand than to come up with a correct algorithm to do it for you?