How many occurences of the empty string in a string?

69 Views Asked by At

Given two strings s and t, we can ask how many occurences of s are in t. For example, "bb" occurs in "bbbb" 3 times. But how many occurences of the empty string are in a string? How would we define that?

1

There are 1 best solutions below

0
On BEST ANSWER

My immediate approach would be to reformulate the question to

How many different pairs of strings $(x,y)$ are there such that $t=xsy$?

If $s$ is the empty string, the answer to this is $|t|+1$.