Official
B - Wild Card Editorial by en_translator
Original proposer: vwxyz
If \(S\) matches \(T\), then for \(i=1,2,\dots,N\), \(T_i\) equals either \(S_i\) or *.
Conversely, if this is satisfied, then \(S\) matches \(T\), so it is sufficient to determine this.
Sample code in C++:
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin>>N;
string S,T;
cin>>S>>T;
string ans="Yes";
for(int i=0;i<N;i++){
if(T[i]!=S[i]&&T[i]!='*'){
ans="No";
}
}
cout<<ans<<"\n";
}
Sample code in Python:
N=int(input())
S=input()
T=input()
if all(t in s+"*" for s,t in zip(S,T)):
ans="Yes"
else:
ans="No"
print(ans)
posted:
last update: