I was reading a book which tellls that the outer loops time complexity is O(n-m) whereas for inner loop the books gives explanation as
" The inner while
loop goes around at most m times, and potentially far less when the pattern match
fails. This, plus two other statements, lies within the outer for loop. The outer loop
goes around at most n−m times, since no complete alignment is possible once we
get too far to the right of the text. The time complexity of nested loops multiplies,
so this gives a worst-case running time of O((n − m)(m + 2)). "
i didn't understand for what reason the time complexity of inner loop is O(m+2) instead of O(m) ?please help thanks