'.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cover the entire input string (not partial). The function prototype should be: bool isMatch(const char *s, const char *p) Some examples: isMatch("aa","a") → false isMatch("aa","aa") → true isMatch("aaa","aa") → false isMatch("aa", "a*") → true isMatch("aa", ".*") → true isMatch("ab", ".*") → true isMatch("aab", "c*a*b") → true
构造状态机,以正则表达式的长度作为状态,对当前所有激活的状态给予当前字符以及空字符,获取新的激活状态
class Solution { public: // 0 acc and next // 1 acc loop or next // 2 not acc,quit // 3 not acc, go next int acc(int state,int input){ if(input==-1000){ if(state>500)return 1; else return 2; } if(state<500){ if(state==input)return 0; else return 2; } else if(state==500)return 0; else if(state==1500)return 1; else{ if(state-1000==input) return 1; else return 2; } return 0; } bool Process(vector<int>& state,vector<bool>&stateb,vector<bool>&tmpstate,int j,int val){ int k; switch(val){ case 0: tmpstate[j+1]=true; return true; case 1: tmpstate[j]=true; k=j+1; while(k<stateb.size()){ if(state[k-1]<=500)break; tmpstate[k]=true; k++; } return true; default: return false; } } bool isMatch(const char *s, const char *p) { // Start typing your C/C++ solution below // DO NOT write int main() function vector<int> state; int i=0; while(p[i]!='