1 less than largest power of 2 greater than n
Approach\n- - Find the next larget power of 2 i.e. ceil(log2(n+1))\n- Then reurn power of 2 to the number found above and then - 1 to have all bits set.\n\n# Co
# Approach\n- - Find the next larget power of 2 i.e. ceil(log2(n+1))\n- Then reurn power of 2 to the number found above and then - 1 to have all bits set.\n\n# Code\n```cpp []\nint smallestNumber(int n) {\n    return pow(2, ceil(log2(n+1))) - 1;\n}\n```\n\n\n\n---\n\n\n<b>Here is an article of my interview experience - A Journey to FAANG Company, I recomand you to go through this to know which all resources I have used & how I cracked interview at Amazon:\nhttps://leetcode.com/discuss/interview-experience/3171859/Journey-to-a-FAANG-Company-Amazon-or-SDE2-(L5)-or-Bangalore-or-Oct-2022-Accepted\n\n\n---\n
['C++']