Practice Concatenation of Consecutive Binary Numbers
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Medium#1680
LeetCode ProblemConcatenation of Consecutive Binary Numbers
Problem Statement
Given an integer n, return the decimal value of the binary string formed by concatenating the binary representations of 1 to n in order, modulo 10^9 + 7.
Source: Concatenation of Consecutive Binary Numbers on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
n = 1
Output
1
# Example 2
Input
n = 3
Output
27
# Example 3
Input
n = 12
Output
505379714
Constraints
1 <= n <= 10^5
Related LeetCode Problems
Practice more problems similar to Concatenation of Consecutive Binary Numbers.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.