-
Notifications
You must be signed in to change notification settings - Fork 33
Added Python solution for 1078. OccurrencesAfterBigram #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@JoyKrishan, use snake case for variable names |
class Solution: | ||
def findOcurrences(self, text: str, first: str, second: str) -> List[str]: | ||
arrayOfWords = text.split() | ||
thirdWords = list() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a blank line below
thirdWords = list() | ||
for i in range(1, len(arrayOfWords) - 1): | ||
if arrayOfWords[i] == second and arrayOfWords[i-1] == first: | ||
thirdWords.append(arrayOfWords[i+1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a blank line below
if arrayOfWords[i] == second and arrayOfWords[i-1] == first: | ||
thirdWords.append(arrayOfWords[i+1]) | ||
return thirdWords | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unnecessary blank lines from here
arrayOfWords = text.split() | ||
thirdWords = list() | ||
for i in range(1, len(arrayOfWords) - 1): | ||
if arrayOfWords[i] == second and arrayOfWords[i-1] == first: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[i-1]
should be [i - 1]
thirdWords = list() | ||
for i in range(1, len(arrayOfWords) - 1): | ||
if arrayOfWords[i] == second and arrayOfWords[i-1] == first: | ||
thirdWords.append(arrayOfWords[i+1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[i+1]
should be [i + 1]
Added Python solution for 1078. OccurrencesAfterBigram. #72