sp
for string s
and tp
for string t
, starting at 0.c
to keep track of the matching characters.s
using the sp
pointer.
a. If s[sp]
equals t[tp]
, increment both sp
and tp
, and increment the counter c
.
b. If they do not match, only increment sp
.sp
reaches the end of s
.t
minus the counter c
.