Day 6 Bitwise Operators HackerRank JavaScript

preview_player
Показать описание
10 Days of Javascript, HackerRank Day 6 Bitwise Operators
Please subscribe, like, and share for more new videos on the YouTube.

Solution explanation:
Because K less or equal N the condition (K-1 OR K less or equal N) is always true in cases where K-1 is even.
In cases where K-1 is odd, the condition (K-1 OR K less or equal N) sometimes evaluates to false (the lowest higher number is bigger than N), in which case the answer is K-2. When it evaluates to true, the answer is K-1.
Рекомендации по теме
Комментарии
Автор

can you please explain in detail this logic?

rock_
Автор

how would it be using AND bit by bit ( &) ?

hezler