diff --git a/dynamic_programming/regex_match.py b/dynamic_programming/regex_match.py index efe7cce9e..6e5a3805a 100644 --- a/dynamic_programming/regex_match.py +++ b/dynamic_programming/regex_match.py @@ -30,11 +30,8 @@ def recursive_match(text: str, pattern: str) -> bool: >>> recursive_match('aa', '.*') True """ - if not text and not pattern: - return True - - if text and not pattern: - return False + if not pattern: + return not text if not text: return pattern[-1] == "*" and recursive_match(text, pattern[:-2])