leetcode 696. Count Binary Substrings
来源:互联网 发布:java招聘系统源代码 编辑:程序博客网 时间:2024/04/30 23:08
class Solution {
public:
int countBinarySubstrings(string s) {
int cur0=0;
int cur1=0;
int sum=0;
for(int i=0;i<=s.size()-1;i++)
{
if(s[i]=='0'){
cur0++;
if(cur0<=cur1)
sum++;
}
if(s[i]=='1'){
cur1++;
if(cur1<=cur0)
sum++;
}
if(i!=s.size()-1&&s[i]!=s[i+1])
{
if(s[i]=='0')
cur1=0;
else
cur0=0;
}
}
return sum;
}
};
阅读全文
0 0
- leetcode 696. Count Binary Substrings
- leetcode-696. Count Binary Substrings
- leetcode 696. Count Binary Substrings
- leetcode 696. Count Binary Substrings
- Count Binary Substrings(leetcode)
- leetcode题解-696. Count Binary Substrings
- 696. Count Binary Substrings
- 696. Count Binary Substrings
- 696. Count Binary Substrings
- 696. Count Binary Substrings
- leetcode 696 Count Binary Substrings
- LeetCode-Easy-Java-Count Binary Substrings
- LeetCode之Count Binary Substrings(Kotlin)
- LWC 54:696. Count Binary Substrings
- python--leetcode696. Count Binary Substrings
- Count Binary Substrings问题及解法
- Codechef Count Substrings
- 451 D. Count Good Substrings
- Estun伺服驱动器生产方案
- MYSQL错误代码#1045 Access denied for user 'root'@'localhost'
- Divided Land
- linux安装mysql和使用c语言操作数据库的方法 c语言连接mysql
- OpenStack oslo.messaging使用
- leetcode 696. Count Binary Substrings
- java基础实践---非递归用栈实现查找迷宫路径
- [UnityEditor基础]EditorStyles 编辑样式
- 于飞岳的
- 环境变量PATH,cp命令,mv命令
- spring-cloud-config + spring-cloud-bus实现动态刷新集群配置
- 数据结构学习记录-二叉树的遍历
- 题目“输入数字星期,输出英文”——代码调试有误
- n个数的最小公倍数