Simple Java Code || Beats 100%
Complexity\n- Time complexity:\nO(n)\n- Space complexity:\nO(1)\n# Code\n\nclass Solution {\n    public int bitwiseComplement(int n) {\n        int allOne = 1;\
# Complexity\n- Time complexity:\nO(n)\n- Space complexity:\nO(1)\n# Code\n```\nclass Solution {\n    public int bitwiseComplement(int n) {\n        int allOne = 1;\n        while(allOne < n){\n            allOne = allOne*2+1;\n        }\n        return allOne - n;\n    }\n}\n```
['Java']