result
to store the boolean values for each query.queries
list.queryIndex
and patternIndex
both set to 0.queryIndex
.queryIndex
and patternIndex
point to matching characters, increment both pointers.queryIndex
is an uppercase letter and does not match the character at patternIndex
, break the loop and mark the query as not matching.queryIndex
is a lowercase letter, only increment queryIndex
.patternIndex
is equal to the length of the pattern, it means all characters in the pattern were matched, so the query matches the pattern. Add true
to result
.false
to result
.result
list.