✅ C++ | Hand Written Explanation | O(n) | ✅
\n\n\n\nclass Solution {\npublic:\n    int concatenatedBinary(int n) {\n     \n        long long int i=1, k=1, z, sum = 1, bit, M = 1e9+7;\n        \n        wh
\n![image](https://assets.leetcode.com/users/images/4e2c3444-ae8d-4f8e-92f6-2998b7e7ec9f_1663958420.934887.jpeg)\n\n```\nclass Solution {\npublic:\n    int concatenatedBinary(int n) {\n     \n        long long int i=1, k=1, z, sum = 1, bit, M = 1e9+7;\n        \n        while(i != n)\n        {\n            z = pow(2,k);\n            bit = pow(2,k+1);\n            k++;\n    \n            while(z-- && i != n)\n            {\n                i++;\n                sum = ((sum*bit)%M + i)%M;\n            }\n        }\n        return sum%M;\n    }\n};  \n```\n\uD83D\uDC47 Please Upvote if you find helpful \u2764
['C']