# Monthly Archives: June 2017

## 448B

Problem Link View Code #include<bits/stdc++.h> using namespace std; #define all(s) sort(s.begin(),s.end()) string s,t; bool ar() {all(s);all(t); return s==t; } bool autom() { int c=0,sz=0; int l=s.size(); for(int i=0;i<l;i++) { if(s[i]==t[c]) c++,sz++; } return sz==t.size()?1:0; } bool bt() { all(s); … Continue reading

## 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

## 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

## 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