Data Structures & Algorithms in Java – Binary – Number of 1 bits in an integer

Problem: Given an integer , count the number of 1 bits in it when converted to a binary Input: 8 Output: 1 (since the binary representation of 8 is 1000 and it has a single 1 bit) Try out the solution here: https://leetcode.com/problems/number-of-1-bits/ Solution: One way to solve this problem is to do AND operation … Continue reading Data Structures & Algorithms in Java – Binary – Number of 1 bits in an integer

0 Comments

Copy and paste this URL into your WordPress site to embed

Copy and paste this code into your site to embed