Match wildcard paths as text
Match the whole text against a glob pattern: question mark matches one character and star matches any sequence including empty. All other characters are literal, including slash.
previous = [True, False, False]
current = [True]
for i in range(1, len(previous)):
current.append(previous[i] or current[i-1])
print(current)Reason about the state
A rolling dynamic-programming row records matches for text prefixes. A star combines its empty match with extending the same star by one character. Before writing code, identify what each variable means after one iteration. Walk through the example and explain why the next transition preserves that meaning. Then check the smallest permitted input and a case with repeated values. A correct answer follows the contract for every input, including the boundary cases in the checks. Keep any input mutation within the stated rules; return a fresh result when the task asks for one.
Your task
Match the whole text against a glob pattern: question mark matches one character and star matches any sequence including empty. All other characters are literal, including slash.
The explanation opens here once every check passes.