-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add Boyer-Moore Majority Vote algorithm #560
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
Add Boyer-Moore Majority Vote algorithm #560
Conversation
90953e6 to
2d98762
Compare
|
@siriak , I've made one algorithm and made PR for review, please check and let me know if you have any feedback, Thanks. |
|
Please fix the issues Codacy found |
- Add curly braces to single-statement if blocks (lines 16, 28) - Split multi-statement lines into separate lines (lines 16, 28) - Declare variables separately instead of comma-separated (line 24)
|
@siriak I've fixed all issues what Codacy found for this PR also, please check it again, Thanks. |
- Change null check from 'nums?.Length == 0' to 'nums == null || nums.Length == 0' - Fixes NullReferenceException when passing null array
4dd44c3 to
94b4f75
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #560 +/- ##
=========================================
Coverage ? 96.86%
=========================================
Files ? 289
Lines ? 11903
Branches ? 1717
=========================================
Hits ? 11530
Misses ? 237
Partials ? 136 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
siriak
left a comment
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.
Looks good, thanks!
Implements Boyer-Moore Majority Vote algorithm for finding majority elements in O(n) time and O(1) space.
Includes 10 test cases covering edge cases and various scenarios.
Contribution by Gittensor, learn more at https://gittensor.io/