Mọi người cho em xin ý tưởng bài này với ạ, em làm bị sai test 2 và em cảm thấy thuật toán của em ko đc chuẩn ạ!
Đề bài: http://laptrinhphothong.vn/Problem/Details/5870
#include <bits/stdc++.h>
using namespace std;
string s;
int dem = 0, tmp;
int main()
{
cin>>s;
for(int i=0;i<s.size()-1;i++)
{
for(int j=i+1;j<s.size();j++)
{
tmp =0;
for(int z=i;z<=j;z++)
{
if(s[z]==s[z+1]) tmp++;
}
if(tmp==0) dem++;
}
}
cout<<dem;
}