Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Added code for Regular Expression Matching #3809
Open
+39
−0
Conversation
https://leetcode.com/problems/regular-expression-matching/ | ||
""" | ||
def isMatch(self, s: str, p: str) -> bool: |
mrmaxguns
Nov 5, 2020
Contributor
Python naming conventions state that function names should be in snake case and one letter variable names are not acceptable. Also, there is no need for a self
argument as the function isn't a class method:
def is_match(check_string: str, pattern: str) -> bool:
...
Python naming conventions state that function names should be in snake case and one letter variable names are not acceptable. Also, there is no need for a self
argument as the function isn't a class method:
def is_match(check_string: str, pattern: str) -> bool:
...
https://leetcode.com/problems/regular-expression-matching/ | ||
""" | ||
def isMatch(self, s: str, p: str) -> bool: | ||
dp = [[0 for i in range(len(p)+1)] for j in range(len(s)+1)] |
mrmaxguns
Nov 5, 2020
Contributor
What is dp
? Variable names should be short, but descriptive.
What is dp
? Variable names should be short, but descriptive.
|
||
for i in range(1,len(s)+1): | ||
for j in range(1,len(p)+1): | ||
if(p[j-1]==s[i-1] or p[j-1]=="."): |
mrmaxguns
Nov 5, 2020
Contributor
The parentheses are unnecessary and redundant:
if p[j - 1] == s[i - 1] or p[j - 1] == ".":
...
The parentheses are unnecessary and redundant:
if p[j - 1] == s[i - 1] or p[j - 1] == ".":
...
if(p[j-1]==s[i-1] or p[j-1]=="."): | ||
dp[i][j] = dp[i-1][j-1] | ||
|
||
elif(j>1 and p[j-1]=="*"): |
mrmaxguns
Nov 5, 2020
Contributor
These parentheses can be removed.
These parentheses can be removed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}
.