Java
Java copied to clipboard
Added Count Total Set Bits from 1 to N (Bit Manipulation)
Description
This PR adds an implementation for counting the total number of set bits from 1 to N using bit manipulation.
The algorithm efficiently counts bits using mathematical observation and avoids iterating through all numbers, running in O(log N) time.
Type of change
- [x] New Algorithm/Data Structure
Checklist
- [x] Code follows TheAlgorithms/Java style and package structure
- [x] SpotBugs, Checkstyle, and CodeQL pass
- [x] Added Javadoc documentation
- [x] Added JUnit test cases
- [x] Verified correctness with multiple examples
Hey @DenizAltunkapan @yanglbme @alxkm 👋 can you please review this PR , I have cleared all the checks can you merge my PR. Thanks.