Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save KhaledElshamy/359335195aa5765cf77408931478b3ab to your computer and use it in GitHub Desktop.
Save KhaledElshamy/359335195aa5765cf77408931478b3ab to your computer and use it in GitHub Desktop.
(B) Bear and Strings Solution -Codeforces
// working.cpp by Bill Weinman <http://bw.org/>
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
int count=0;
cin>>s;
for(int i=0;i<s.size();i++)
{
int find=(s.substr(i)).find("bear");
//cout<<s.size()<<" "<<find<<" "<<s.substr(i).size()<<endl;
if(find!=-1)
count+=1+s.substr(i).size()-find-4;
}
cout<<count<<endl;
return 0;
}
@AnanyaDasgupta
Copy link

Can you please explain your approach?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment