Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Lonely Ones Binary ones ( 1 ) can get lonely if only zeros ( 0 ) surround them. Formally, we call such 1 ' s
Lonely Ones
Binary ones can get lonely if only zeros
surround them. Formally, we call such s "sparse". A
number is defined as sparse if its binary
representation has no two consecutive bits set.
You are given an integer and your task is to find
out if it is sparse or not.
Input
The input contains an integer
Output
'Print if the number is sparse and if the number
is not sparse.
Constraints
Example #
Explanation: The binary representation of
There are no consecutive ones present in
this. So it is a sparse number.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started