Created
March 14, 2017 13:51
-
-
Save KhaledElshamy/359335195aa5765cf77408931478b3ab to your computer and use it in GitHub Desktop.
(B) Bear and Strings Solution -Codeforces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} |
Can you please explain your approach?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thx!