Loading...
Given two integers low and high, return how many integers x with low <= x <= high have a binary representation that contains "101" as a contiguous substring.
The binary representation is written without leading zeros. For example, 5 is "101" and 10 is "1010"; both contain "101".
Input: low = 1, high = 10
Output: 2
Explanation: 5 ("101") and 10 ("1010") contain "101"; no other value in [1, 10] does.
Input: low = 6, high = 9
Output: 0
Explanation: None of "110", "111", "1000", "1001" contains "101".
Input: low = 5, high = 5
Output: 1
low ≤ high ≤9⋅1015Click "Run" to test with sample cases or "Submit" to run all tests.