Last active
March 4, 2020 18:00
-
-
Save deque-blog/874b9ff11e5f07abcf19d5899a4f9447 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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