Monthly Archives: June 2017

GSS1

#Problem Link Prerequisites: 1.¬† e-maxx     View Code #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll mx = 50010; ll a[mx]; struct data { int sum, pref, suff, ans ; }tree[4*mx] ; data make_data ( ll val … Continue reading

Rate this:

Posted in Uncategorized | Leave a comment

126B – Password

This problem is based on Z- algorithm To learn this algorithm¬† – Click here!   View Code #include<bits/stdc++.h> using namespace std; void solve(string s) { int l=s.size(); int z[l]; int left,right; left=right=0; for(int k=1;k<l;k++) { if(k>right) { left=right=k; while(right { … Continue reading

Rate this:

Posted in Uncategorized | Leave a comment

Z algorithm

Today we will try with a new algorithm – Z algorithm This algo is used in pattern matching,there is another algo for pattern matching This algorithm works in O(length of text+length of pattern) complexity and space complexity is similar to … Continue reading

Rate this:

Posted in Uncategorized | Leave a comment