res
to 0.i
in string s
.i
, iterate over each character index j
in string t
.(i, j)
, initialize miss
to 0 and pos
to 0.i + pos
is within s
and j + pos
is within t
, do the following:
a. If s[i + pos]
is not equal to t[j + pos]
, increment miss
.
b. If miss
is greater than 1, break the loop.
c. If miss
is exactly 1, increment res
.
d. Increment pos
.res
.