Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped consecutively. Substrings that occur multiple times are counted the numbe…
本题先寻找字符串中0变1,或者1变0的位置作为分隔位置.然后从这个分隔位置同时向左.右两侧搜索. 找到的左连续串和右连续串,都进行累计. public class Solution { public int CountBinarySubstrings(string s) { //s = "00110011"; //这道题的思路是先找到分割点,然后用分割点,向两边同时搜索,找到连续串 var len = s.Length; ) { ; } ; ].ToString(); ; i <…