• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
October 31, 2023 |770 Views

SDE Sheet - Sparse Number

  Share  2 Likes
Description
Discussion

This video is part of the Bit Manipulation section under the GFG SDE Sheet.

In this problem, we are given, a number N. The task is to check whether it is sparse or not. A number is said to be a sparse number if no two or more consecutive bits are set in the binary representation.

Example :

Input: N = 2
Output: 1

Explanation: Binary Representation of 2 is 10, which is not having consecutive set bits. 
So, it is sparse number.

Try it out before watching the implementation of the problem in the video. We recommend watching the video, even if you can solve the problem. You may discover something new. All the best!!!

Do check out:-

Article: https://www.geeksforgeeks.org/check-if-a-given-number-is-sparse-or-not/
Problem: https://practice.geeksforgeeks.org/problems/number-is-sparse-or-not-1587115620/1
SDE Sheet Link: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/