Posts

1[0]....1 pattern finding

                             Pattern finding  #include <bits/stdc++.h> using namespace std; void solve() { string str; cin>>str; regex r("1[0]+1"); smatch m; int count=0; while(regex_search(str,m,r)) // this function is searching for the regular expression in the string { int index=m.position(0)+m.length()-1;// for this case 10101 (answer should be 2 in this case) str=str.substr(index);              // after firstmatch we need to start our next search from index 2 ++count;   //increment the counter every times a string matches with regular expression } cout<<count<<"\n";   } int main(){ int t; cin>>t; while(t--) { solve(); } return 0; }

My competitive Programming Profiles

Image
My github repository:- sanathvernekar My kaggle profile:- sanathvernekar My stopstalk profile:- lilliput My competitive Programming Profiles hackerrank profile:- sanath_vernekar hackerearth profile:- lilliput Geeks for Geeks profile:- sanath_vernekar SPOJ profile:- sanath_v codechef profile:- sanath_v TopCoder profile:- sanath_vernekar codeforces profile:- sanath URI profile:- sanath vernekar