Question is :
Write a function
int f(char* str, long pattern)
to find out how many pattern does the str contain? str is a char array consist of '1' and '0';
for example: str = "11010101110101011110100011001" ,pattern = 110;
My solution is change pattern and str to std::string, then use std::string::find to search.
but I think this solution is not efficient.
1.Could you tell me other efficient solution? thanks.
2. if the second parameter is a array, how to optimize it?
Thank you very much!