We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
functiongetMaxLessThanK(n,k){letmax=0;for(leti=1;i<n;i++)for(letj=i+1;j<=n;j++)if(max<(i&j)&&(i&j)<k){max=(i&j);if(max===k-1)returnmax;// since it's the most expected value}returnmax;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 6: Bitwise Operators
You are viewing a single comment's thread. Return to all comments →
This was my answer