[OTHER] Make `BoyerMoore.findmajor` return `java.util.Optional<Integer>`
vil02 opened this issue ยท 5 comments
vil02 commented
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
.
prathameshpowar1910 commented
Could you assign this issue to me?
vil02 commented
@prathameshpowar1910 when you will create a PR closing this, please mention me.
prathameshpowar1910 commented
prathameshpowar1910 commented
@vil02 There is some issue with the linting could you solve that?