Concatenation of Consecutive Binary Numbers | Leetcode #1680

preview_player
Показать описание
This video explains an interesting interview problem which is find the decimal value of the binary string obtained after concatenating all the numbers from 1 to N in order. Given a number N, we need to create a string by concatenating the binary representations of all the numbers from 1 to N in order.The resulting string is then converted into it's equivalent decimal number modulo 10^9 + 7. This is done to avoid integer overflow.I have first shown the naive approach for solving the problem and then shown the intuition for solving the problem using efficient approach by showing the important observations.I have also shown a dry run and the code explanation at the end of the video.CODE LINK is present below as usual. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)

========================================================================
Join this channel to get access to perks:

=======================================================================

USEFUL LINKS:-

#bit #leftshift #bitoperation
Рекомендации по теме
Комментарии
Автор

well explained! I lost in the discussion sections where they were talking all math.
You saved my streak !

a.nk.r
Автор

Sir, I really appreciate the way you explained this problem.

shreyasingh
Автор

Awesome explanation sir.
This question was purely based on observation skills.
Rather easy for those who observed the test cases carefully

shubhamagrawal
Автор

Really loved the solution. Hats off for your work sir.

rehanakhter
Автор

only imp part is getting the length of integer num by using => 1+log (num) in (base2)

jaatharsh
Автор

Can't you avoid the log by just doing P*2x+x? 2^D simplifies to just 2x using exponentiation rules

anonymoussloth
Автор

Anyone can please explain why the total number of digits is log2(N) + 1 in a number?

SR-wevl
visit shbcf.ru