Skip to content

Conversation

aadil42
Copy link
Contributor

@aadil42 aadil42 commented Jun 7, 2023

Added solution for find-the-index-of-the-first-occurrence-in-a-string in JS

File(s) Added: 0028-find-the-index-of-the-first-occurrence-in-a-string.js
Language(s) Used: JavaScript
Submission URL: https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string/submissions/985281830/

Added solution for find-the-index-of-the-first-occurrence-in-a-string in JS
}
}

j = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: fix empty space and be consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the spacing is fixed.

} else if(j !== 0 && needle[j] === needle[i]) {
pattern[i] = 1 + pattern[j - 1];
i++;
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: simplify your conditions and avoid else

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a kind reminder that I updated the code as suggested.

Avoiding else cases with continue where possible.
@aadil42
Copy link
Contributor Author

aadil42 commented Sep 5, 2023

The solution to this problem has been added by someone. I'm closing the PR.

@aadil42 aadil42 closed this Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants