I have written a program, in which I have to find the number of occurrences (overlapping + non-overlapping) of a string in another string.// variable to keep track of wordint i=0;for(vector<string>::iterator it = p.begin(); it!=p.end(); it++){    frequency[i]=0;    int start=0;    while(true){        start = s.find(*it, start);        if(start==-1){  // not found            break;        } else{            frequency[i]++;            start++;        }    }    i++;}I am finding the starting index start of the match, and then again searching for the string starting from 'start+1' this time, and so on. The length of the string s, in which searching has to be performed is 50,00,000. And total number of keywords (stored in vector p here) is 500 (each having length of 5000).
Finding the number of occurrences of a string in another string
c++;optimization;strings