[Java/C++/Python] Different ideas
Explanation\nSolution 1. while loop on res = res * 2 + 1\nSolution 2. Build-in count leading zeros\nSolution 3. Build-in count bit length\n\n# Complexity\nTime 
# **Explanation**\nSolution 1. while loop on `res = res * 2 + 1`\nSolution 2. Build-in count leading zeros\nSolution 3. Build-in count bit length\n\n# **Complexity**\nTime `O(logn)`\nSpace `O(1)`\n<br>\n\n**Java**\n```Java\n    public int smallestNumber(int n) {\n        int res = 1;\n        while (res < n)\n            res = res * 2 + 1;\n        return res;\n    }\n```\n```Java\n    public int smallestNumber(int n) {\n        return -1 >>> Integer.numberOfLeadingZeros(n);\n    }\n```\n**C++**\n```C++\n    int smallestNumber(int n) {\n        return (1 << (32 - __builtin_clz(n))) - 1;\n    }\n\n    int smallestNumber(int n) {\n        return INT_MAX >> __builtin_clz(n) - 1;\n    }\n```\n**Python**\n```py [Python3]\n    def smallestNumber(self, n: int) -> int:\n        return (1 << n.bit_length()) - 1\n```
['C', 'Python', 'Java']