ends0 and ends1 to keep track of the number of subsequences ending with '0' and '1', respectively.has0 to keep track of whether there is at least one '0' in the binary string.ends1 to ends0 + ends1 + 1.ends0 to ends0 + ends1 and set has0 to 1.ends0 + ends1 + has0.10^9 + 7.