![]() |
Given an integer N, the task is to find the absolute difference between the number of set bits present in the number N and in reverse of the number N. Examples:
Approach: The main idea is to use the bitset function of the STL library. Follow the steps below to solve the given problem:
Below is the implementation of the above approach: C++14
Java
Python3
C#
Javascript
Output:
2
Time Complexity: O(log N)
|
Reffered: https://www.geeksforgeeks.org
Bit Magic |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 11 |