i
and j
to 0 for name
and typed
respectively.j
is less than the length of typed
:
a. If i
is less than the length of name
and name[i]
equals typed[j]
, increment both i
and j
.
b. Else if j
is greater than 0 and typed[j]
equals typed[j-1]
, increment j
only.
c. Else, return false
.i
equals the length of name
, return true
. Otherwise, return false
.