Skip to content

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

Merged
merged 3 commits into from
Oct 15, 2022

Conversation

JoyKrishan
Copy link
Contributor

Added Python solution for 1078. OccurrencesAfterBigram. #72

@Tahanima
Copy link
Owner

@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()
Copy link
Owner

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])
Copy link
Owner

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

Copy link
Owner

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:
Copy link
Owner

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])
Copy link
Owner

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]

@Tahanima Tahanima merged commit d357891 into Tahanima:main Oct 15, 2022
@JoyKrishan JoyKrishan deleted the leetcode-1078 branch June 29, 2023 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants