godricly.li
BAN USERthe description is kind of wield.Like we only need 2 record the order the char appears???? abcd goes 2 aabbccccbbaa...how about aba? thats aaaa? what does the 2nd and 3rd iteration mean here ?
- godricly.li October 16, 2013R we just looking for pairs which have different digits?
like 10,3;10,110
we can reduce the search space by this.
try this?
inspired the the recursive approach.Processing the string from the end.
#include<iostream>
using namespace std;
bool isMatch(char* sA,char* sB,int iALength,int iBLength)
{
if(iALength==0&&iBLength==0)
return true;
else
{
if(iALength>0)
{
if(sA[iALength-1]=='*')
return isMatch(sA,sB,iALength-1,iBLength)||isMatch(sA,sB,iALength-2,iBLength);
if(sA[iALength-1]=='.')
return isMatch(sA,sB,iALength-1,iBLength)||isMatch(sA,sB,iALength-1,iBLength-1);
if(iBLength>0)
{
if(sA[iALength-1]==sB[iBLength-1])
return true;
else
return false;
}
}
else
return false;
}
}
int main()
{
char* sA;
char* sB;
int iALength;
int iBLength;
sA=new char[7];
sB=new char[4];
sA="ab*c*d.";
sB="abdg";
iALength=7;
iBLength=4;
if(isMatch(sA,sB,iALength,iBLength))
cout<<"match"<<endl;
else
cout<<"not match"<<endl;
return 0;
}
578, isnt this in an increasing order?????
- godricly.li October 16, 2013