// two string
// string test= "abcdef"
// string pattern = "abc*f"
// expected output = true
// test 1 =" jkabapq"
// string test= "abcdef"
// string pattern = abc*g*
// expected output = false
// string test= "abcdefggijkgh"
// string pattern = "abc*g*h"
// expected output = true
// string test= "abcdef"
// string pattern = abc?e
// expected output = false
// bool =
// ? = 1 character
// * multiple character
#include<bits/stdc++.h>
using namespace std;
bool solve(string test, string pattern)
{
// string test= "abcdefggijkgh";
// string pattern = "abc*g*h";
int n=test.size();
int m=pattern.size();
int left=0;
int right=0;
for(int i=0;i<m;i++)
{
if(test[left]==pattern[right])
{
left++;
right++;
}
else
{
if(test[left]=='*' && left<n)
{
bool flag=false;
int pos=left;
int temp=right;
while(temp<m)
{
if(test[left+1]==pattern[temp])
{
pos=left;
flag=false;
}
}
if(flag==false)
return false;
}
}
}
return true;
}
int main()
{
string test= "abcdefggijkgh";
string pattern = "abc*g*h";
cout<<solve(test,pattern);
}
Ly8gdHdvIHN0cmluZyAKCi8vIHN0cmluZyB0ZXN0PSAgImFiY2RlZiIKLy8gIHN0cmluZyBwYXR0ZXJuID0gImFiYypmIgoKLy8gZXhwZWN0ZWQgb3V0cHV0ID0gdHJ1ZQoKLy8gdGVzdCAxID0iIGprYWJhcHEiCgoKLy8gc3RyaW5nIHRlc3Q9ICAiYWJjZGVmIgovLyAgc3RyaW5nIHBhdHRlcm4gPSBhYmMqZyoKCi8vIGV4cGVjdGVkIG91dHB1dCA9IGZhbHNlCgovLyBzdHJpbmcgdGVzdD0gICJhYmNkZWZnZ2lqa2doIgovLyBzdHJpbmcgcGF0dGVybiA9ICJhYmMqZypoIgoKLy8gZXhwZWN0ZWQgb3V0cHV0ID0gdHJ1ZQoKCi8vIHN0cmluZyB0ZXN0PSAgImFiY2RlZiIKLy8gIHN0cmluZyBwYXR0ZXJuID0gYWJjP2UKCi8vIGV4cGVjdGVkIG91dHB1dCA9IGZhbHNlCgoKLy8gYm9vbCA9IAoKLy8gPyA9IDEgY2hhcmFjdGVyCi8vICogbXVsdGlwbGUgY2hhcmFjdGVyCgoKI2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmJvb2wgc29sdmUoc3RyaW5nIHRlc3QsIHN0cmluZyBwYXR0ZXJuKQp7CiAgICAvLyBzdHJpbmcgdGVzdD0gICJhYmNkZWZnZ2lqa2doIjsKICAgIC8vIHN0cmluZyBwYXR0ZXJuID0gImFiYypnKmgiOwogICAgaW50IG49dGVzdC5zaXplKCk7CiAgICBpbnQgbT1wYXR0ZXJuLnNpemUoKTsKICAgIAogICAgaW50IGxlZnQ9MDsKICAgIGludCByaWdodD0wOwogICAgCiAgICBmb3IoaW50IGk9MDtpPG07aSsrKQogICAgewogICAgICAgIGlmKHRlc3RbbGVmdF09PXBhdHRlcm5bcmlnaHRdKQogICAgICAgIHsKICAgICAgICAgICAgbGVmdCsrOwogICAgICAgICAgICByaWdodCsrOwogICAgICAgIH0KICAgICAgICBlbHNlCiAgICAgICAgewogICAgICAgICAgICBpZih0ZXN0W2xlZnRdPT0nKicgJiYgbGVmdDxuKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBib29sIGZsYWc9ZmFsc2U7CiAgICAgICAgICAgICAgICBpbnQgcG9zPWxlZnQ7CiAgICAgICAgICAgICAgICBpbnQgdGVtcD1yaWdodDsKICAgICAgICAgICAgICAgIHdoaWxlKHRlbXA8bSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZih0ZXN0W2xlZnQrMV09PXBhdHRlcm5bdGVtcF0pCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBwb3M9bGVmdDsKICAgICAgICAgICAgICAgICAgICAgICAgZmxhZz1mYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgIGlmKGZsYWc9PWZhbHNlKQogICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgIAogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgCiAgICByZXR1cm4gdHJ1ZTsKfQppbnQgbWFpbigpCnsKICAgIHN0cmluZyB0ZXN0PSAgImFiY2RlZmdnaWprZ2giOwogICAgc3RyaW5nIHBhdHRlcm4gPSAiYWJjKmcqaCI7CiAgICBjb3V0PDxzb2x2ZSh0ZXN0LHBhdHRlcm4pOwp9CgoKCgoK