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
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:
...| 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)] |
|
|
||
| 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] == ".":
...| 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]=="*"): |
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}.