Simple & Easy |  O(n log n) | O(n)
Since we are concatenating binary numbers from left to right , for every number we have to left shift our result floor[ log(n)+1] times and add our current numb
Since we are concatenating binary numbers from left to right , for every number we have to **left shift our result floor[ log(n)+1]** times and **add our current number** .\n```\nE.g. Consider 3\nres = 0                1 (1)                110 ( 1<<2 (i.e.log(2)+1) + 2)                               11011 ( 110<<2 (i.e. log(3)+1) + 3)  \n1 to N                    1                                     2                                               3\n```\n\n```\nclass Solution {\npublic:\n    int log2(int n ){\n        int c = 0;\n        while(n>1){\n          n /=2;\n            c++;\n        }\n        return c;\n    }\n    \n    int concatenatedBinary(int n) {\n    \n        int mod = 1e9+7;\n        long long ans = 0;\n        for(int i =1;i<=n;i++){\n            \n            int a = log2(i)+1; \n            ans = ans << a;\n            ans = ans + i;\n            if(ans>mod){\n                ans = ans%mod;\n            }\n            \n        }\n       \n        return ans%mod;\n    }\n};\n```\n**Time Complexity : O(n logn)\nSpace Complexity : O(1)**\n\n**Note :** This can be easily reduced to **O(n)** if we keep the count of bits from the start of the loop .
['C']