-
Notifications
You must be signed in to change notification settings - Fork 19.9k
Code for LowestSetBitManipulation added #5574
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
Code for LowestSetBitManipulation added #5574
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5574 +/- ##
============================================
+ Coverage 53.96% 53.98% +0.01%
- Complexity 3387 3390 +3
============================================
Files 535 536 +1
Lines 15429 15432 +3
Branches 2942 2942
============================================
+ Hits 8327 8331 +4
Misses 6749 6749
+ Partials 353 352 -1 ☔ View full report in Codecov by Sentry. |
@ishanki19-pixel The PR for which you're providing a fix already had clearLowestSetBit(int n) from it's initial commits, and it already handles corner cases like 0s and negative numbers. |
@prayas7102 Yeah, I was bit confused with testing stuff, I am resolving this in a while. |
b74a362
to
e2398ba
Compare
@prayas7102 Please review this once again! |
Hey @ishanki19-pixel I'm not the reviewer for this repository; I'm also a contributor. What I was asking is, all the changes you've made in this PR are already present in PR #5567. So, what is the purpose of this PR? |
But this pr is itself #5574 , its id is itself 5574. I am not able to understand what are you trying to saying because you are referring the same PR in which you are commenting now |
Sorry for the confusion, it's #5567 which i was trying to refer. |
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.
Please resolve conflicts
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution! |
Please reopen this pull request once you have made the required changes. If you need help, feel free to ask in our Discord server or ping one of the maintainers here. Thank you for your contribution! |
Pull Request: Added
LowestSetBit
Class for Efficient Bit Manipulation( Fix: #5567)Description
This pull request introduces the
LowestSetBit
class, which provides efficient methods for isolating and clearing the lowest set bit of an integer using bitwise operations.Key Features
isolateLowestSetBit(int n)
: Returns the value of the lowest set bit in the given integer.clearLowestSetBit(int n)
: Returns the integer with its lowest set bit cleared.Edge Case Handling
n = 0
by returning0
(no set bits).Performance Analysis
O(1)
due to direct bitwise operations.O(1)
, as no additional space is used beyond the input variable.Checklist
clang-format -i --style=file path/to/your/file.java
.