prokawsar's blog

By prokawsar, history, 8 years ago, In English

What is the best way to match a string or part of a string in C language ? It could be whole string or such as "develop" took from "development". I used to solve this problem with some loops, but it getting TLE for large size in Length. Which way would be efficient ?

Thanks

  • Vote: I like it
  • -3
  • Vote: I do not like it

| Write comment?
»
8 years ago, # |
Rev. 2   Vote: I like it +5 Vote: I do not like it

KMP (Knuth-Morris-Pratt algorithm) and Rabin-Karp algorithm.

»
8 years ago, # |
Rev. 2   Vote: I like it +7 Vote: I do not like it

I have once got AC with just strstr function in the problem where KMP was expected. Try it out.