-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
feat: Modified count_set_bits.cpp #1634
Conversation
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 fix clang-tidy
warnings.
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.
Almost there! 😄
#include <cassert> // for assert | ||
#include <iostream> // for I/O operations |
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.
#include <cassert> // for assert | |
#include <iostream> // for I/O operations | |
#include <cassert> /// for assert | |
#include <iostream> /// for IO operations |
* @namespace count_of_set_bits | ||
* @brief Functions for the [count sets | ||
* bits](https://www.geeksforgeeks.org/count-set-bits-in-an-integer/) | ||
* implementation | ||
*/ |
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.
* @namespace count_of_set_bits | |
* @brief Functions for the [count sets | |
* bits](https://www.geeksforgeeks.org/count-set-bits-in-an-integer/) | |
* implementation | |
*/ | |
* @namespace count_of_set_bits | |
* @brief Functions for the [count sets | |
* bits](https://www.geeksforgeeks.org/count-set-bits-in-an-integer/) | |
* implementation | |
*/ |
int main() | ||
{ | ||
test(); // run self-test implementations | ||
return 0; | ||
} | ||
} |
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 fix the indentation in this part of the code.
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.
Done. :)
* We are given an integer number. Let’s say, number. The task is to first | ||
* calculate the binary digit of a number and then calculate the total set bits | ||
* of a number. | ||
* We are given a integer number. We need to calculate number of set bits in it. |
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.
* We are given a integer number. We need to calculate number of set bits in it. | |
* We are given an integer number. We need to calculate the number of set bits in it. |
* bits](https://www.geeksforgeeks.org/count-set-bits-in-an-integer/) in an | ||
* integer. | ||
* @brief Implementation to [count number of set bits of a number] | ||
* (https://www.geeksforgeeks.org/count-set-bits-in-an-integer/) |
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.
* (https://www.geeksforgeeks.org/count-set-bits-in-an-integer/) | |
* (https://www.geeksforgeeks.org/count-set-bits-in-an-integer/) in an | |
* integer. |
Co-authored-by: David Leal <halfpacho@gmail.com>
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.
Almost there! 😄
Co-authored-by: David Leal <halfpacho@gmail.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
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.
Awesome work! Thank you for your contribution! 😄👍🎉
You can join our Discord server and get the contributor role! 🚀
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.
@prashant-th18: LGTM! 🥳
Changed the algorithm of Finding set-bits of a number which is much faster than previous one.
Checklist
Notes: