Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Last active March 4, 2020 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deque-blog/874b9ff11e5f07abcf19d5899a4f9447 to your computer and use it in GitHub Desktop.
Save deque-blog/874b9ff11e5f07abcf19d5899a4f9447 to your computer and use it in GitHub Desktop.
def match(self, s: str) -> bool:
current_nodes = { 0 }
self.expand_selection(current_nodes)
for c in s:
next_nodes = set()
for s in current_nodes:
if s < len(self.nodes):
if self.nodes[s] == c or self.nodes[s] == '.':
next_nodes.add(s+1)
if self.stars[s]:
next_nodes.add(s)
self.expand_selection(next_nodes)
current_nodes = next_nodes
if not current_nodes:
return False
last_node = max(current_nodes)
return len(self.nodes) == last_node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment