我正在接受亚马孙关于职业资格的约谈,我从这个令人感兴趣的问题来到这里,我没有能够说明如何做。 我自两天以来一直在思考这一问题。 要么我走了一条路,要么是真心实意的书写功能。
www.un.org/Depts/DGACM/index_spanish.htm 问题如下:
Write a function in C that can find if a string is a sub-string of another. Note that a mismatch of one character should be ignored.
A mismatch can be an extra character: ’dog’ matches ‘xxxdoogyyyy’
A mismatch can be a missing character: ’dog’ matches ‘xxxdgyyyy’
A mismatch can be a different character: ’dog’ matches ‘xxxdigyyyy’
这里提到的回报价值是没有的,因此,我假定这一功能的签名可以这样:
char * MatchWithTolerance(const char * str, const char * substr);
如果与特定规则相匹配,则把点人送回在地狱中搭配的距离。 遣返无效。
<<>Bonus
If someone can also figure out a generic way of making the tolerance to n instead of 1, then that would be just brilliant. In that case the signature would be:
char * MatchWithTolerance(const char * str, const char * substr, unsigned int tolerance = 1);