s_idx
and p_idx
to 0, and variables star_idx
and s_tmp_idx
to -1.s_idx
while s_idx < s.length()
.p_idx < p.length()
and the characters at s_idx
and p_idx
match (or p[p_idx]
is ?
), increment both s_idx
and p_idx
.p_idx < p.length()
and p[p_idx]
is *
, record the star position in star_idx
, increment p_idx
, and set s_tmp_idx
to s_idx
.p_idx
is at the end), check if there was a previous *
by looking at star_idx
.*
, backtrack: set p_idx
to star_idx + 1
, increment s_tmp_idx
, and set s_idx
to s_tmp_idx
.*
exists, return False
.p_idx
is not at the end, check if the remaining characters in p
are all *
.True
if all remaining characters in p
are *
; otherwise, return False
.