is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
#include<iostream>
- spandanpathak August 12, 2012#include<string>
using namespace std;
struct node
{
char a;
node *l;
int flag;
}*start;
bool matchReg(node *q,int i);
string t,p;
int n,m;
int main()
{
start=NULL;
node *temp,*q;
cin>>t;
cin>>p;
n=t.length();
m=p.length();
int i;
i=0;
if(t[i]=='*')
i++;
while(i<n-1)
{
if(t[i+1]=='*' && t[i]!='*')
{
if(start==NULL)
{
start=new node;
start->a=t[i];
start->l=NULL;
start->flag=1;
temp=start;
}
else
{
q=new node;
q->a=t[i];
q->l=NULL;
q->flag=1;
temp->l=q;
temp=q;
}
}
else if(t[i]!='*')
{
if(start==NULL)
{
start=new node;
start->a=t[i];
start->l=NULL;
start->flag=0;
temp=start;
}
else
{
q=new node;
q->a=t[i];
q->l=NULL;
q->flag=0;
temp->l=q;
temp=q;
}
}
i++;
}
if(t[i]!='*')
{
if(start==NULL)
{
start=new node;
start->a=t[i];
start->l=NULL;
start->flag=0;
temp=start;
}
else
{
q=new node;
q->a=t[i];
q->l=NULL;
q->flag=0;
temp->l=q;
temp=q;
}
}
if(matchReg(start,0))
cout<<"Accepted";
else
cout<<"Rejected";
}
bool matchReg(node *q,int i)
{
if(q==NULL && i==m)
return true;
else if(q==NULL && i!=m)
return false;
else if(q->l==NULL && q->flag==1 && i==m)
return true;
else if(q!=NULL && i==m)
return false;
else if(q->a!=p[i] && q->flag==0)
return false;
else if(q->a==p[i] && q->flag==0)
return matchReg(q->l,i+1);
else
{
bool b1=matchReg(q->l,i+1);
bool b2=matchReg(q,i+1);
bool b3=matchReg(q->l,i);
return (b1||b2||b3);
}
}