面试题,怎么查找一个字符串里的最长连续字符?
Find the longest run in a string
怎么查找一个字符串里的最长连续相同字符?
int longestrun(char* str)
{
// e.g. input ddbbbcxg, return 3 (because bbb has 3 b's in a row)
// e.g. input hello, return 2 (because ll has 2 l's in a row)
}
longestrun("Gooooodbye")); // should output 5
longestrun("Interesting")); // should output 1