title: Runtime of brute force string-matching algorithm
body: <p>I've written a small, quick (to write, not to run!), algorithm for string matching in Python:</p>
  
  <pre><code>def bruteMatch(n,m):
      for i in range(0,len(n)-len(m)+1):
          if n[i:len(m)+i]==m:
              return(i)
  </code></pre>
  
  <p>Would the runtime for this algorithm be O(nm)? I'm comparing it to the worst-case runtime for the Horspool string-matching algorithm, which is also (nm). I guess my confusion stems from the fact that my algorithm appears initially as O(n) runtime as it simply iterates through the input n, using the indices as inputs to a slice notation equality statement? Thoughts?</p>