动态规划-匹配问题

问题描述:

  Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'.

  '?' Matches any single character.

  '*' Matches any sequence of characters (including the empty sequence).

问题分析:

  用opt[i][j]表示s的起始到第i个位置与p的起始到第j个位置的匹配关系。

  如果p[j-1]=s[i-1]或者p[j-1]='?':opt[i][j]=opt[i-1][j-1];

  如果p[j-1]='*':opt[i][j]=True,any{opt[i-k][j-1]=True|k in [0,i]};否则False ;

  否则:opt[i][j]=False

生活的味道
原文地址:https://www.cnblogs.com/jgongzh/p/10510354.html