class StringPattern {
public:
int findAppearance(string A, int lena, string B, int lenb) {
// write code here
for(int i=0;i<lena;i++){
if(A[i]==B[0]){ //找到首字母了
if(lenb==1) return i;
for(int j =1;j<lenb;j++){ //继续寻找下面的
if(A[i+j]!=B[j]){
break;
}
if(j==lenb-1){
return i;
}
}
}
}
return -1;
}
};



京公网安备 11010502036488号