class Solution {
public int countBinarySubstrings(String s) {
int result = 0;
char[] chars = s.toCharArray();
for(int i = 1; i < s.length(); i++){
int left = i - 1, right = i;
char leftChar = chars[left], rightChar = chars[right];
// 不对称
if(leftChar == rightChar) continue;
// 边界条件,向外扩展
while(left >= 0 && right < s.length() &&
chars[left] == leftChar && chars[right] == rightChar){
left--;
right++;
result++;
}
}
return result;
}
}