1 static int wing=[]()
 2 {
 3     std::ios::sync_with_stdio(false);
 4     cin.tie(NULL);
 5     return 0;
 6 }();
 7 
 8 class Solution 
 9 {
10 public:
11     int countBinarySubstrings(string s) 
12     {
13         int count=0;
14         int pre=0,cur=1;
15         int len=s.length();
16         for(int i=1;i<len;i++)
17         {
18             if(s[i]==s[i-1])
19                 cur++;
20             else
21             {
22                 count+=min(pre,cur);
23                 pre=cur;
24                 cur=1;
25             }             
26         }
27         return count+min(pre,cur);
28     }
29 };

简单快捷

posted on 2018-06-10 16:20  高数考了59  阅读(106)  评论(0)    收藏  举报