Skip to content

style: use getOrDefault in MajorityElement #5454

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

Conversation

vil02
Copy link
Member

@vil02 vil02 commented Sep 18, 2024

This PR simplifies the logic inside the majority method.

The background story is that I was experimenting with infer and it was reporting a potential Null dereference (there are about 29 left). In this case it will not happen, but the code can be written better (as in this PR). I am considering including infer into our CI. I will keep you updated.

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 52.03%. Comparing base (2f9f448) to head (33e6d27).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5454      +/-   ##
============================================
- Coverage     52.03%   52.03%   -0.01%     
+ Complexity     3238     3237       -1     
============================================
  Files           524      524              
  Lines         15181    15179       -2     
  Branches       2888     2887       -1     
============================================
- Hits           7900     7898       -2     
  Misses         6956     6956              
  Partials        325      325              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vil02 vil02 marked this pull request as ready for review September 18, 2024 17:13
@alxkm alxkm merged commit 7bde152 into TheAlgorithms:master Sep 18, 2024
5 checks passed
@vil02 vil02 deleted the use_getOrDefault_in_MajorityElement branch September 19, 2024 08:27
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.

3 participants