Geekina gifted Geek a number 'n', and since Geek is away, he asked you to count the number of
times the sequence "101" occurs as a subsequence in the binary representation of 'n'.
Example 1:
Input:
n = 5
Output:
1
Explanation:
5 in binary is 101, hence "101" only occurring once as the subsequence.
Example 2:
Input:
n = 21
Output:
4
Explanation:
21 in binary is 10101. "101" is occurring as a subsequence in 4 ways viz. -
10101
10101
10101
10101
Your Task:
You don't need to read input or print anything. Your task is to complete the
function count101() which takes an 64-bit integer n as the input and returns the count of number
----
找101子序列的数量,当遇到1的时候,计算前面子字符串的10出现的次数,然后累加即可。
计算10出现的次数,单独写一个函数即可。