c++ - Search string for string sequence -


what efficient way count number of occurrences of substring in string in c++? example, have huge string like

"gqwhiwqghwggeeegqihigwhiqwghieeegphiqpiwghqpwgpheeegqihwpwgqhpqwgeee" 

and want count how "eee" occurs.

i go step step in loop , check every letter if it's e , if so, count them , if there 3 es, increment counter, guess there more efficient way of doing this.

maybe string function? wasn't able find or google suitable one.

i searching clean c++11 solution.

well, if want fast , efficent solution, take @ knuth–morris–pratt algorithm - takes o(n+m) search. if want in stl style, take @ std::string::find


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -