采用动态规划,去看力扣44题就知道 怎么做了

import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String s=null;
        while((s=br.readLine())!=null){
            String ss=br.readLine();
           
            s=s.toLowerCase();
            ss=ss.toLowerCase();
            char sss[]=ss.toCharArray();
            char ppp[]=s.toCharArray();
            
            boolean dp[][]=new boolean[ppp.length+1][sss.length+1];
            dp[0][0]=true;
            for(int i=1;i<=ppp.length;i++){
                if(ppp[i-1]=='*'){
                    dp[i][0]=true;
                }else break;
                
            }
            for(int i=1;i<=ppp.length;i++){
                for(int j=1;j<=sss.length;j++){
                    if(ppp[i-1]==sss[j-1]){
                        dp[i][j]=dp[i-1][j-1];
                    }
                    if(ppp[i-1]=='?'&&((sss[j-1]>='a'&&sss[j-1]<='z')||(sss[j-1]>='0'&&sss[j-1]<='9'))){
                        dp[i][j]=dp[i-1][j-1];
                    }else if(ppp[i-1]=='*'&&((sss[j-1]>='a'&&sss[j-1]<='z')||(sss[j-1]>='0'&&sss[j-1]<='9'))){
                        dp[i][j]=dp[i-1][j]|dp[i][j-1]|dp[i-1][j-1];
                    }
                    //System.out.print(dp[i][j]+"  ");
                }
                //System.out.print("\n");
            }
            System.out.println(dp[ppp.length][sss.length]);
        }
    }
}