2
* find all bit switches '01' and '10'.3
* From each one expand sideways: i goes left, j goes right5
* if '01' -> i,j != 0,16
* if '10' -> i,j != 1,07
* and within input boundaries9
var countBinarySubstrings = function (s) {14
if (s[i] != s[i + 1]) {16
count += countZeroOnes(s, i, true);18
count += countZeroOnes(s, i, false);25
// count the number of valid substrings substrings26
function countZeroOnes(s, start, startsWithZero) {32
while (i >= 0 && j < n && s[i] === "0" && s[j] === "1") {38
while (i >= 0 && j < n && s[i] === "1" && s[j] === "0") {