Skip to content
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

[OTHER] Make BoyerMoore.findmajor return java.util.Optional<Integer> #4949

Closed
vil02 opened this issue Oct 30, 2023 · 5 comments
Closed

[OTHER] Make BoyerMoore.findmajor return java.util.Optional<Integer> #4949

vil02 opened this issue Oct 30, 2023 · 5 comments
Assignees

Comments

@vil02
Copy link
Member

vil02 commented Oct 30, 2023

What would you like to share?

Current implementation of BoyerMoore.findmajor returns -1 in case when there is no majority element. This is confusing, since the input array could contain -1. I suggest to change this method to return java.util.Optional<Integer>.

Additional information

Solving this is a goof opportunity to clean up the existing code, I would suggest to introduce new private methods like findCandidate, calculateOccurrences and isMajority.

@vil02 vil02 added awaiting triage Awaiting triage from a maintainer enhancement and removed awaiting triage Awaiting triage from a maintainer labels Oct 30, 2023
@prathameshpowar1910
Copy link
Contributor

Could you assign this issue to me?

@vil02
Copy link
Member Author

vil02 commented Oct 30, 2023

@prathameshpowar1910 when you will create a PR closing this, please mention me.

@prathameshpowar1910
Copy link
Contributor

@vil02 i have opened a PR #4951 but the build is failing could you look into it?

@vil02 vil02 mentioned this issue Oct 31, 2023
6 tasks
@prathameshpowar1910
Copy link
Contributor

@vil02 There is some issue with the linting could you solve that?

@vil02
Copy link
Member Author

vil02 commented Oct 31, 2023

Solved by #4951.

@vil02 vil02 closed this as completed Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants